本文整理了Java中android.widget.Spinner.<init>()
方法的一些代码示例,展示了Spinner.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spinner.<init>()
方法的具体详情如下:
包路径:android.widget.Spinner
类名称:Spinner
方法名:<init>
暂无
代码示例来源:origin: stackoverflow.com
Spinner spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerArray); //selected item will look like a spinner set from XML
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerArrayAdapter);
代码示例来源:origin: stackoverflow.com
Spinner spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, spinnerArray);
spinnerArrayAdapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
spinner = (Spinner) findViewById( R.id.spinner );
spinner.setAdapter(spinnerArrayAdapter);
代码示例来源:origin: ankidroid/Anki-Android
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
boolean b = savedInstanceState.getBoolean(BUNDLE_KEY_SHUT_OFF, false);
if (b) {
finishCancel();
return;
}
}
setContentView(R.layout.activity_load_pronounciation);
mSource = getIntent().getExtras().getString(EXTRA_SOURCE);
LinearLayout linearLayout = findViewById(R.id.layoutInLoadPronActivity);
mLanguageLister = new LanguageListerBeolingus();
mSpinnerFrom = new Spinner(this);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
mLanguageLister.getLanguages());
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinnerFrom.setAdapter(adapter);
linearLayout.addView(mSpinnerFrom);
Button buttonLoadPronunciation = new Button(this);
buttonLoadPronunciation.setText(gtxt(R.string.multimedia_editor_pron_load));
linearLayout.addView(buttonLoadPronunciation);
buttonLoadPronunciation.setOnClickListener(v -> onLoadPronunciation(v));
Button mSaveButton = new Button(this);
mSaveButton.setText("Save");
mSaveButton.setOnClickListener(v -> { });
mActivity = this;
mStopped = false;
}
代码示例来源:origin: cSploit/android
public SpinnerDialog(String title, String message, String[] items, int default_index, FragmentActivity activity, final SpinnerDialogListener listener){
super(activity);
Spinner mSpinner = new Spinner(activity);
mSpinner.setAdapter(new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_item, items));
mSpinner.setOnItemSelectedListener(new OnItemSelectedListener(){
public void onItemSelected(AdapterView<?> adapter, View view, int position, long id){
mSelected = position;
}
public void onNothingSelected(AdapterView<?> arg0){
}
});
mSpinner.setSelection(default_index);
this.setTitle(title);
this.setMessage(message);
this.setView(mSpinner);
this.setButton(BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id){
listener.onItemSelected(mSelected);
}
});
this.setButton(BUTTON_NEGATIVE, activity.getString(R.string.cancel_dialog), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
}
代码示例来源:origin: stackoverflow.com
super.onCreate(savedInstanceState);
Spinner s = new Spinner(this);
AbsListView.LayoutParams params = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT
代码示例来源:origin: ankidroid/Anki-Android
mSpinnerFrom = new Spinner(this);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
mLanguageLister.getLanguages());
linearLayout.addView(tvTo);
mSpinnerTo = new Spinner(this);
ArrayAdapter<String> adapterTo = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
mLanguageLister.getLanguages());
代码示例来源:origin: ankidroid/Anki-Android
final Spinner addSelectionSpinner = new Spinner(this);
ArrayAdapter<String> mNewModelAdapter = new ArrayAdapter<>(this, R.layout.dropdown_deck_item, mNewModelLabels);
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() throws Exception {
context = ApplicationProvider.getApplicationContext();
spinner = new Spinner(context);
shadowSpinner = shadowOf(spinner);
String [] testItems = {"foo", "bar"};
arrayAdapter = new MyArrayAdapter(this.context, testItems);
}
代码示例来源:origin: stackoverflow.com
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
LinearLayout layout = new LinearLayout(this);
ArrayList<String> spinnerArray = new ArrayList<String>();
spinnerArray.add("one");
spinnerArray.add("two");
spinnerArray.add("three");
spinnerArray.add("four");
spinnerArray.add("five");
Spinner spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
layout.addView(spinner);
setContentView(layout);
}
代码示例来源:origin: stackoverflow.com
for (int i = 0; i <5; i + +) {
sp = new Spinner (this);
sp.setAdapter (un_adapter);
sp.setTag(i.toString());
sp.setOnItemSelectedListener (this);
}
代码示例来源:origin: stackoverflow.com
for (int i = 0; i <5; i + +) {
sp = new Spinner (this);
sp.setId(R.id.defined_0+i);
sp.setAdapter (un_adapter);
sp.setOnItemSelectedListener (this);
}
代码示例来源:origin: stackoverflow.com
Spinner dropdown = new Spinner(this);
//TODO attach to an adapter of some sort
getSupportActionBar().setCustomView(dropdown);
getSupportActionBar().setDisplayShowCustomEnabled(true);
代码示例来源:origin: stackoverflow.com
public void initSpinner(JSONArray jsonArray)
{
Spinner spinner = new Spinner(this);
JSONArrayAdapter jsonArrayAdapter = new JSONArrayAdapter(this, countries, "Name");
spinner.setAdapter(jsonArrayAdapter);
}
代码示例来源:origin: stackoverflow.com
Spinner spinner = new Spinner(this);
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item,
new String[] { "Apple", "Peach", "Banana" });
spinner.setAdapter(spinnerArrayAdapter);
代码示例来源:origin: stackoverflow.com
View linearLayout = findViewById(R.id.layoutID);
Cerate spinner
Spinner spinner = new Spinner(this);
//Make sure you have valid layout parameters.
spinner .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item, spinnerList);
spinner.setAdapter(spinnerArrayAdapter);
Then add spinner to view
((LinearLayout) linearLayout).addView(spinner );
代码示例来源:origin: stackoverflow.com
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < 2; i++) {
Spinner spinner = new Spinner(this);
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list.get(i));
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
ll.addView(spinner, params);
}
alert.setView(ll);
代码示例来源:origin: stackoverflow.com
Spinner s1 = findViewById(R.id.spinner01);
ArrayAdapter a = new ArrayAdapter(/*/required stuff*/,array1)
s1.setAdapter(a);
s1.setOnClickListener(new OnClickListener(){
protected void onClick(View v){
Spinner s = new Spinner(/*/activity Instance*/);
ArrayAdapter a1 = new ArrayAdapter(/*/required stuff*/,array2)
s.setAdapter(a1);
//rest goes here
}
});
代码示例来源: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
Spinner spinner = new Spinner(this);
spinner .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item, spinnerList);
spinner.setAdapter(spinnerArrayAdapter);
代码示例来源:origin: termux/termux-api
@Override
Spinner createWidgetView(AppCompatActivity activity) {
Spinner spinner = new Spinner(activity);
final Intent intent = activity.getIntent();
final String[] items = getInputValues(intent);
final ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, R.layout.spinner_item, items);
spinner.setAdapter(adapter);
return spinner;
}
}
内容来源于网络,如有侵权,请联系作者删除!