android.widget.Spinner.setId()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中android.widget.Spinner.setId()方法的一些代码示例,展示了Spinner.setId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spinner.setId()方法的具体详情如下:
包路径:android.widget.Spinner
类名称:Spinner
方法名:setId

Spinner.setId介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

for(int i=1;i<4;i++)
{
  Spinner spin=new Spinner(getApplicationCotext());
  spin.setId(i);
  ...
  //other code
  ...
  mLayout.add(spin);//add this spinner to your layout(mLayout is object of your layout in xml)
}

代码示例来源:origin: stackoverflow.com

Spinner spinner = new Spinner(context);
spinner.setId(R.id.defined);

代码示例来源:origin: stackoverflow.com

//add spinner
Spinner spinner = new Spinner(home_screen.this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(home_screen.this, android.R.layout.simple_spinner_dropdown_item, spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
spinner.setId(android.R.id.list);
row.addView(spinner);

代码示例来源:origin: stackoverflow.com

LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 LinearLayout layout=(LinearLayout)this.findViewById(R.id.parentLayout);
 for (int i = 0 ; i<3; i++){
   Spinner spinner = (Spinner) layoutInflater.inflate(R.layout.spinner, null);
   spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, array));
   spinner.setId(i);
   spinner.setSelection(i);
   layout.addView(spinner);
 }

代码示例来源:origin: stackoverflow.com

Spinner spinner = new Spinner(this);
   spinner.setAdapter(spinChildAdapter);
   parentSpinner.addView(spinner);
   spinner.setId(totalDynamicChild); //the spinner's id will be the increment from 0
   spinnderIdList.add(totalDynamicChild); //list of the dynamic spinner ID
   totalDynamicChild++;

代码示例来源:origin: stackoverflow.com

for(int i=0;i<4;i++){

final Spinner spinner= new Spinner(context);
  spinner.setId(i);
  ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArray);
      spinner.setAdapter(spinnerArrayAdapter);

    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
      @Override
      public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

          switch(parent.getId()){
case "0": //your code
case "1": //your code
...
}

        }
      }

      @Override
      public void onNothingSelected(AdapterView<?> adapterView) {

      }
    });

代码示例来源:origin: stackoverflow.com

public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(getActivity(), R.array.showmessages,R.layout.spinner_item);
    list.setDropDownViewResource(R.layout.spinner_dropdown_item);
    inflater.inflate(R.menu.message, menu);
    MenuItem item = (MenuItem) menu.findItem(R.id.menu_mode);
    Spinner spinner = (Spinner) new Spinner(getActivity());
    spinner.setId(R.id.spinner1);
    item.setActionView(spinner);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);


message.xml 

<item android:id="@+id/menu_mode"
  android:showAsAction="always"
  android:title="@string/action_bar_spinner"
  android:actionViewClass="android.widget.spinner" />

代码示例来源:origin: derry/delion

/**
 * Creates a standard spinner and adds it to the layout.
 */
public <T> Spinner addSpinner(int spinnerId, ArrayAdapter<T> arrayAdapter) {
  Spinner spinner = (Spinner) LayoutInflater.from(getContext()).inflate(
      R.layout.infobar_control_spinner, this, false);
  spinner.setAdapter(arrayAdapter);
  addView(spinner, new ControlLayoutParams());
  spinner.setId(spinnerId);
  return spinner;
}

代码示例来源:origin: stackoverflow.com

spinner = new Spinner(DynamicSpiner.this);
spinnerDependent = new Spinner(DynamicSpiner.this);
spinner.setId(i);
spinnerDependent.setId(i);
hashMap.put(i, spinnerDependent);
spinner.setOnItemSelectedListener(this);

代码示例来源:origin: li2/learning-android-open-source

mSpinner.setId(R.id.spinner);
mSpinner.setAdapter(adapter);
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

代码示例来源:origin: qiubiteme/android_api_demos

mSpinner.setId(R.id.spinner);
mSpinner.setAdapter(adapter);
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

代码示例来源:origin: stackoverflow.com

else if(v == btnAddChild)
 {
   LinearLayout dynamicLayout = new LinearLayout(this);
   LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
   params.weight = 1.0f;
   params.gravity = Gravity.CENTER_VERTICAL;
   dynamicLayout.setLayoutParams(params);
   dynamicLayout.setOrientation(LinearLayout.HORIZONTAL);
   int layoutId = totalDynamicChild + 1000; //dynamicLayout always have dynamic spinnser's id + 1000 to avoid same id
   dynamicLayout.setId(layoutId);
   Spinner spinner = new Spinner(this);
   spinner.setLayoutParams(params);
   spinner.setAdapter(spinChildAdapter);
   spinner.setId(totalDynamicChild);   
   spinnderIdList.add(totalDynamicChild);
   ImageButton btn = new ImageButton(this);
   btn.setImageDrawable(getResources().getDrawable(R.drawable.action_delete));
   btn.setBackgroundResource(0);
   btn.setLayoutParams(params);
   int btnId = totalDynamicChild + 2000; //btn always have dynamic spinnser's id + 2000 to avoid same id
   btn.setId(btnId);
   dynamicLayout.addView(spinner);
   dynamicLayout.addView(btn);
   parentSpinner.addView(dynamicLayout);
   totalDynamicChild++;

代码示例来源:origin: MiEcosystem/mijiaSDK

AllowedValueAdapter adapter = new AllowedValueAdapter(this, list);
  spinner.setAdapter(adapter);
  spinner.setId(argId++);
  argView.addView(spinner);
} else {

代码示例来源:origin: dkharrat/NexusDialog

@Override
protected View createFieldView() {
  Spinner spinnerView = new Spinner(getContext());
  spinnerView.setId(spinnerId);
  spinnerView.setPrompt(prompt);
  ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, items) {

相关文章