最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android下拉列表spinner的實例代碼

 更新時間:2016年05月27日 16:39:45   作者:summerpxy  
這篇文章主要為大家詳細(xì)介紹了Android下拉列表spinner的實例代碼。感興趣的小伙伴們可以參考一下

spinner組件有點類型于HTML中的下拉框<Select></select>的樣子,讓用戶每次從下拉框中選取一個,本文為大家分享了Android下拉列表spinner的具體實現(xiàn)代碼,供大家參考,具體內(nèi)容如下

mian.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical"
 tools:context=".Main" >

 <Spinner
  android:id="@+id/spinner"
  android:layout_width="300sp"
  android:layout_height="50sp"
  android:layout_gravity="center_horizontal" />

</LinearLayout>

Main.java

package com.app.main;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class Main extends Activity {

 Spinner spinner = null;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  spinner = (Spinner) this.findViewById(R.id.spinner);
  ArrayAdapter adapter = new ArrayAdapter(this,
    android.R.layout.simple_spinner_item, new String[] { "第一項",
      "第二項", "第三項" });

  //設(shè)置下拉樣式
  adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
  spinner.setAdapter(adapter);
 }

}

效果圖:

其中主要涉及到兩個xml文件,一個是填充數(shù)據(jù)時的simple_spinner_item.xml和下拉樣式simple_dropdown_item_1line

simple_spinner_item.xml:

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
 android:id="@android:id/text1"
 style="?android:attr/spinnerItemStyle"
 android:singleLine="true"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:ellipsize="marquee"
 android:textAlignment="inherit"/>

simple_dropdown_item_1line.xml:

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
 android:id="@android:id/text1"
 style="?android:attr/dropDownItemStyle"
 android:textAppearance="?android:attr/textAppearanceLargePopupMenu"
 android:singleLine="true"
 android:layout_width="match_parent"
 android:layout_height="?android:attr/listPreferredItemHeight"
 android:ellipsize="marquee" />

以上就是本文的全部內(nèi)容,希望對大家學(xué)習(xí)Android軟件編程有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • android studio3.0以上如何通過navicat訪問SQLite數(shù)據(jù)庫文件

    android studio3.0以上如何通過navicat訪問SQLite數(shù)據(jù)庫文件

    這篇文章主要介紹了android studio3.0以上如何通過navicat訪問SQLite數(shù)據(jù)庫文件,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06
  • Android使用viewpager實現(xiàn)自動無限輪播圖

    Android使用viewpager實現(xiàn)自動無限輪播圖

    這篇文章主要介紹了Android使用viewpager實現(xiàn)自動無限輪播圖效果,實現(xiàn)方法大概有兩種,一種是viewpager+作為游標(biāo)的點 。另外一種是重寫viewpager,具體實現(xiàn)過程大家參考下本文
    2018-06-06
  • 安卓11適配攻略搶先看

    安卓11適配攻略搶先看

    這篇文章主要介紹了安卓11適配攻略搶先看,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-10-10
  • 詳解OpenGL Shader抗鋸齒的實現(xiàn)

    詳解OpenGL Shader抗鋸齒的實現(xiàn)

    普通繪制圓形形狀時可以看到圖形邊緣會有明顯鋸齒現(xiàn)象并不像真實圓形形狀一樣圓潤邊緣平滑。本文將介紹如何通過自制函數(shù)實現(xiàn)抗鋸齒,需要的可以參考一下
    2022-02-02
  • Android自定義Span實現(xiàn)文字漸變效果

    Android自定義Span實現(xiàn)文字漸變效果

    Android提供一些Span設(shè)置文本樣式外,開發(fā)者若希望實現(xiàn)一些新特性也是能自定義開發(fā)實現(xiàn)的。本文就將自定義Span實現(xiàn)文字漸變效果,感興趣的可以嘗試一下
    2022-06-06
  • Android UI控件RatingBar實現(xiàn)自定義星星評分效果

    Android UI控件RatingBar實現(xiàn)自定義星星評分效果

    這篇文章主要為大家詳細(xì)介紹了Android UI控件RatingBar實現(xiàn)自定義星星評分效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-02-02
  • 詳解 Android中Libgdx使用ShapeRenderer自定義Actor解決無法接收到Touch事件的問題

    詳解 Android中Libgdx使用ShapeRenderer自定義Actor解決無法接收到Touch事件的問題

    這篇文章主要介紹了詳解 Android中Libgdx使用ShapeRenderer自定義Actor解決無法接收到Touch事件的問題的相關(guān)資料,希望通過本文能幫助到大家解決這樣的問題,需要的朋友可以參考下
    2017-09-09
  • Android Studio 3.0 原生支持kotlin 例子詳解

    Android Studio 3.0 原生支持kotlin 例子詳解

    這篇文章主要介紹了 Android Studio 3.0 原生支持kotlin 例子詳解,非常具有實用價值,需要的朋友可以參考下
    2017-05-05
  • Android穩(wěn)定性:可遠(yuǎn)程配置化的Looper兜底框架

    Android穩(wěn)定性:可遠(yuǎn)程配置化的Looper兜底框架

    這篇文章主要為大家介紹了Android穩(wěn)定性可遠(yuǎn)程配置化的Looper兜底框架實例實例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • Android實現(xiàn)斷點下載的方法

    Android實現(xiàn)斷點下載的方法

    這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)斷點下載的方法,感興趣的小伙伴們可以參考一下
    2016-03-03

最新評論

三明市| 乌审旗| 沈丘县| 普兰店市| 夏邑县| 专栏| 大同县| 佳木斯市| 禹州市| 开化县| 新津县| 内乡县| 天等县| 余干县| 南投市| 澄迈县| 格尔木市| 穆棱市| 出国| 德安县| 黔南| 泗洪县| 扎囊县| 阳山县| 宝山区| 台中县| 广德县| 永德县| 三河市| 防城港市| 申扎县| 邮箱| 牡丹江市| 新安县| 衡山县| 资阳市| 晴隆县| 莎车县| 永靖县| 布拖县| 长泰县|