1.布局文件内容 :
<?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/target_number" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="60sp" android:layout_marginTop="20sp" > </TextView> <Spinner android:id="@+id/target_pinner" android:layout_width="200sp" android:layout_height="wrap_content" android:layout_marginLeft="60sp" android:layout_marginTop="20sp" > </Spinner> <TextView android:id="@+id/consult_number" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="60sp" android:layout_marginTop="20sp" > </TextView> <Spinner android:id="@+id/consult_spinner" android:layout_width="200sp" android:layout_height="wrap_content" android:layout_marginLeft="60sp" android:layout_marginTop="20sp" > </Spinner> <Button android:id="@+id/manage_operation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="100sp" android:layout_marginTop="20sp" android:text="执行调度" android:textSize="18sp" > </Button> </LinearLayout>
2.JAVA程序代码:
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.protocol.HTTP; import org.json.JSONArray; import org.json.JSONObject; import com.sxzichen.common.MD5Util; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import android.widget.TextView; public class SameQuen_Activity extends Activity implements OnClickListener{ private static final String[] queuinfo={"A01","A02","A03","A04","A05","A06","A07","A08","A09","A10","A11"}; private TextView target_view ; private Spinner target_spinner; private ArrayAdapter<String> target_adapter; private TextView consult_view; private Spinner consult_spinner; private ArrayAdapter<String> consult_adapter; private String targetNumber=""; private String consultMunber=""; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_samequeu); //定义目标排队编号下拉菜单 target_view = (TextView) findViewById(R.id.target_number); target_spinner = (Spinner) findViewById(R.id.target_pinner); //将可选内容与ArrayAdapter连接起来 target_adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,queuinfo); //设置下拉列表的风格 target_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //将adapter 添加到spinner中 target_spinner.setAdapter(target_adapter); //添加事件Spinner事件监听 target_spinner.setOnItemSelectedListener(new BooldSpinnerSelectedListener()); //设置默认值 target_spinner.setVisibility(View.VISIBLE); //定义参照排队编号下拉菜单 consult_view = (TextView) findViewById(R.id.consult_number); consult_spinner = (Spinner) findViewById(R.id.consult_spinner); //将可选内容与ArrayAdapter连接起来 consult_adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,queuinfo); //设置下拉列表的风格 consult_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //将adapter 添加到spinner中 consult_spinner.setAdapter(consult_adapter); //添加事件Spinner事件监听 consult_spinner.setOnItemSelectedListener(new MobleSpinnerSelectedListener()); //设置默认值 consult_spinner.setVisibility(View.VISIBLE); Button manage_operation=(Button)findViewById(R.id.manage_operation); manage_operation.setOnClickListener(this); } //选择 目标排队编号 事件 监听器 class BooldSpinnerSelectedListener implements OnItemSelectedListener{ public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { targetNumber=queuinfo[arg2]; target_view.setText("要移动的排队编号是:"+queuinfo[arg2]); } public void onNothingSelected(AdapterView<?> arg0) { } } // //选择 参照排队编号 事件 监听器 class MobleSpinnerSelectedListener implements OnItemSelectedListener{ public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { consultMunber=queuinfo[arg2]; consult_view.setText("移动到 "+queuinfo[arg2] +" 后边 "); } public void onNothingSelected(AdapterView<?> arg0) { } } @Override public void onClick(View v) { System.out.println(" 进入同一队列调度环节"); System.out.println("执行 把 "+targetNumber+" 移动到 "+consultMunber+" 后边操作 "); // switch(v.getId()){//根据点击不同的按钮,弹出相应的提示 // // 插队 // case R.id.breke_queuing: // System.out.println("进入插队环节"); // startBreakQuening(user_name,estination_code) ; // break; // //队列管理 // case R.id.same_queuing: // System.out.println("进入同一队列管理环节"); // sameMangerQuening(user_name,estination_code) ; // break; // //队列管理 // case R.id.diffrent_queuing: // System.out.println("进入不同队列管理环节"); // diffrentMangerQuening(user_name,estination_code) ; // break; // } } @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; } }
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索android
, spinner
, android adapter
, private
, 队列
, android widget.
, android widget
, jsonarray
, import
, arrayadapter
, android spinner
, spinner多选
, spinner button
adapter android
spinner 下拉菜单高度、android spinner 下拉、android spinner 使用、android 下拉菜单、android 顶部下拉菜单,以便于您获取更多的相关知识。