欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android 之Spinner下拉菜單實(shí)現(xiàn)級聯(lián)

 更新時間:2013年02月25日 21:15:47   作者:  
android 之Spinner下拉菜單實(shí)現(xiàn)級聯(lián),需要的朋友可以參考一下

效果圖如下:

默認(rèn)第一次加載

選擇原始隊(duì)列:

級聯(lián)效果圖:

關(guān)鍵代碼給下拉列表選中事件監(jiān)聽綁定Id :

復(fù)制代碼 代碼如下:

int pos = firsthand_dlbh_pinner.getSelectedItemPosition();
firsthand_pdbh_adapter = new ArrayAdapter<String>(context,
 android.R.layout.simple_spinner_item, queu_info[pos]);
firsthand_pdbh_spinner.setAdapter(firsthand_pdbh_adapter);

完整代碼:

布局文件代碼:

復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/firsthand_dlbh"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="60sp"
        android:layout_marginTop="20sp" >
    </TextView>

    <Spinner
        android:id="@+id/firsthand_dlbh_pinner"
        android:layout_width="200sp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="60sp"
        android:layout_marginTop="20sp" >
    </Spinner>

    <TextView
        android:id="@+id/firsthand_pdbh"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="60sp"
        android:layout_marginTop="20sp" >
    </TextView>

    <Spinner
        android:id="@+id/firsthand_pdbh_pinner"
        android:layout_width="200sp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="60sp"
        android:layout_marginTop="20sp" >
    </Spinner>

    <TextView
        android:id="@+id/target_dlbh"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="60sp"
        android:layout_marginTop="20sp" >
    </TextView>

    <Spinner
        android:id="@+id/target_dlbh_spinner"
        android:layout_width="200sp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="60sp"
        android:layout_marginTop="20sp" >
    </Spinner>

    <Button
        android:id="@+id/diff_manage_operation"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100sp"
        android:layout_marginTop="20sp"
        android:text="執(zhí)行調(diào)度"
        android:textSize="18sp" >
    </Button>

</LinearLayout>


JAVA 程序代碼:
復(fù)制代碼 代碼如下:

import android.app.Activity;
import android.content.Context;

import android.os.Bundle;

import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;

public class ManageInfo_Activity extends Activity implements OnClickListener {
 private Context context;
 private static final String[] queuilist = { "A999", "B888" };
 private static final String[] default_linfo = { "A01", "A02", "A03", "A04",
   "A05", "A06", "A07", "A08", "A09", "A10", "A11" };
 private static final String[][] queu_info = new String[][] {
   { "A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09",
     "A10", "A11" },
   { "B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08", "B09",
     "B10", "B11" } };
 private TextView firsthand_dlbh_view;
 private Spinner firsthand_dlbh_pinner;
 private ArrayAdapter<String> firsthand_dlbh_adapter;

 private TextView firsthand_pdbh_view;
 private Spinner firsthand_pdbh_spinner;
 private ArrayAdapter<String> firsthand_pdbh_adapter;

 private TextView target_dlbh_view;
 private Spinner target_dlbh_spinner;
 private ArrayAdapter<String> target_dlbh_adapter;

 private String firsthand_dlbh = "";
 private String firsthand_pdbh = "";
 private String target_dlbh = "";

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_manageinfo);

  context = this;

  // 定義原始隊(duì)列編號下拉菜單
  firsthand_dlbh_view = (TextView) findViewById(R.id.firsthand_dlbh);
  firsthand_dlbh_pinner = (Spinner) findViewById(R.id.firsthand_dlbh_pinner);
  // 將可選內(nèi)容與ArrayAdapter連接起來
  firsthand_dlbh_adapter = new ArrayAdapter<String>(this,
    android.R.layout.simple_spinner_item, queuilist);
  // 設(shè)置下拉列表的風(fēng)格
  firsthand_dlbh_adapter
    .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  // 將adapter 添加到spinner中
  firsthand_dlbh_pinner.setAdapter(firsthand_dlbh_adapter);
  // 添加事件Spinner事件監(jiān)聽
  firsthand_dlbh_pinner
    .setOnItemSelectedListener(new FirsthanddlbhSpinnerSelectedListener());
  // 設(shè)置默認(rèn)值
  firsthand_dlbh_pinner.setVisibility(View.VISIBLE);

  // 定義原始排隊(duì)編號下拉菜單
  firsthand_pdbh_view = (TextView) findViewById(R.id.firsthand_pdbh);
  firsthand_pdbh_spinner = (Spinner) findViewById(R.id.firsthand_pdbh_pinner);
  // 將可選內(nèi)容與ArrayAdapter連接起來
  firsthand_pdbh_adapter = new ArrayAdapter<String>(this,
    android.R.layout.simple_spinner_item, default_linfo);
  // 設(shè)置下拉列表的風(fēng)格
  firsthand_pdbh_adapter
    .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  // 將adapter 添加到spinner中
  firsthand_pdbh_spinner.setAdapter(firsthand_pdbh_adapter);
  // 添加事件Spinner事件監(jiān)聽
  firsthand_pdbh_spinner
    .setOnItemSelectedListener(new FirsthandpdbhSpinnerSelectedListener());
  // 設(shè)置默認(rèn)值
  firsthand_pdbh_spinner.setVisibility(View.VISIBLE);

  // 定義目標(biāo)隊(duì)列下拉菜單
  target_dlbh_view = (TextView) findViewById(R.id.target_dlbh);
  target_dlbh_spinner = (Spinner) findViewById(R.id.target_dlbh_spinner);
  // 將可選內(nèi)容與ArrayAdapter連接起來
  target_dlbh_adapter = new ArrayAdapter<String>(this,
    android.R.layout.simple_spinner_item, queuilist);
  // 設(shè)置下拉列表的風(fēng)格
  target_dlbh_adapter
    .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  // 將adapter 添加到spinner中
  target_dlbh_spinner.setAdapter(target_dlbh_adapter);
  // 添加事件Spinner事件監(jiān)聽
  target_dlbh_spinner
    .setOnItemSelectedListener(new TargetdlbhpinnerSelectedListener());
  // 設(shè)置默認(rèn)值
  target_dlbh_spinner.setVisibility(View.VISIBLE);

  Button diff_manage_operation = (Button) findViewById(R.id.diff_manage_operation);
  diff_manage_operation.setOnClickListener(this);

 }

 // 選擇 目標(biāo)排隊(duì)編號 事件 監(jiān)聽器
 class FirsthanddlbhSpinnerSelectedListener implements
   OnItemSelectedListener {

  public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
   firsthand_dlbh = queuilist[arg2];
   firsthand_dlbh_view.setText("選擇原始隊(duì)列是:" + queuilist[arg2]);
   int pos = firsthand_dlbh_pinner.getSelectedItemPosition();
   firsthand_pdbh_adapter = new ArrayAdapter<String>(context,
     android.R.layout.simple_spinner_item, queu_info[pos]);
   firsthand_pdbh_spinner.setAdapter(firsthand_pdbh_adapter);

  }

  public void onNothingSelected(AdapterView<?> arg0) {
  }
 }

 // 選擇 目標(biāo)排隊(duì)編號 事件 監(jiān)聽器
 class FirsthandpdbhSpinnerSelectedListener implements
   OnItemSelectedListener {

  public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
   firsthand_pdbh = (String) firsthand_pdbh_spinner
     .getItemAtPosition(arg2);
   firsthand_pdbh_view.setText("要移動的排隊(duì)編號是:"
     + (String) firsthand_pdbh_spinner.getItemAtPosition(arg2));
  }

  public void onNothingSelected(AdapterView<?> arg0) {
  }
 }

 // //選擇 參照排隊(duì)編號 事件 監(jiān)聽器
 class TargetdlbhpinnerSelectedListener implements OnItemSelectedListener {

  public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
   target_dlbh = queuilist[arg2];
   target_dlbh_view.setText("移動到 " + queuilist[arg2] + " 隊(duì)列中 ");
  }

  public void onNothingSelected(AdapterView<?> arg0) {
  }
 }


 @Override
 public void onClick(View v) {

  System.out.println(" 進(jìn)入同一隊(duì)列調(diào)度環(huán)節(jié)");

  System.out.println("執(zhí)行把排隊(duì)編號 " + firsthand_pdbh + " 從 " + firsthand_dlbh
    + " 隊(duì)列中移動到  " + target_dlbh + "   隊(duì)列的末尾操作  ");
 // DiffMangerQuening( user_name, estination_code, firsthand_dlbh, firsthand_dlbh,target_dlbh); // switch(v.getId()){//根據(jù)點(diǎn)擊不同的按鈕,彈出相應(yīng)的提示


 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.activity_main, menu);
  return true;
 }
}

相關(guān)文章

  • Android搜索框(SearchView)的功能和用法詳解

    Android搜索框(SearchView)的功能和用法詳解

    這篇文章主要為大家詳細(xì)介紹了Android搜索框SearchView的功能和用法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Android實(shí)現(xiàn)的ListView分組布局改進(jìn)示例

    Android實(shí)現(xiàn)的ListView分組布局改進(jìn)示例

    這篇文章主要介紹了Android實(shí)現(xiàn)的ListView分組布局改進(jìn)的方法,結(jié)合實(shí)例形式分析了Android針對ListView的分組布局相關(guān)操作技巧,需要的朋友可以參考下
    2016-08-08
  • Android中l(wèi)ayer-list基本使用詳解

    Android中l(wèi)ayer-list基本使用詳解

    這篇文章主要介紹了Android中l(wèi)ayer-list基本使用詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • Android自定義相機(jī)聚焦和顯示框

    Android自定義相機(jī)聚焦和顯示框

    這篇文章主要為大家詳細(xì)介紹了Android自定義相機(jī)聚焦和顯示框,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-01-01
  • Android實(shí)現(xiàn)視頻彈幕功能

    Android實(shí)現(xiàn)視頻彈幕功能

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)視頻彈幕功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • SafeList?in?Flutter?and?Dart小技巧

    SafeList?in?Flutter?and?Dart小技巧

    這篇文章主要為大家介紹了SafeList?in?Flutter?and?Dart小技巧,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-12-12
  • Android HTTP網(wǎng)絡(luò)請求的異步實(shí)現(xiàn)

    Android HTTP網(wǎng)絡(luò)請求的異步實(shí)現(xiàn)

    這篇文章主要介紹了Android HTTP網(wǎng)絡(luò)請求的異步實(shí)現(xiàn),感興趣的小伙伴們可以參考一下
    2016-07-07
  • Android BitmapUtils工具類使用詳解

    Android BitmapUtils工具類使用詳解

    這篇文章主要為大家詳細(xì)介紹了Android BitmapUtils工具類的使用,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • Android自定義View app更新動畫詳解

    Android自定義View app更新動畫詳解

    這篇文章給大家分享了Android自定義View app更新動畫的相關(guān)代碼以及知識點(diǎn)內(nèi)容,有興趣的朋友參考學(xué)習(xí)下。
    2018-07-07
  • Android整理好的圖片壓縮工具類

    Android整理好的圖片壓縮工具類

    今天小編就為大家分享一篇關(guān)于Android整理好的圖片壓縮工具類,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-12-12

最新評論