Example of Android Spinner without and with android:spinnerMode="dialog":
|
Normal Spinner without android:spinnerMode="dialog" |
|
Spinner with android:spinnerMode="dialog" |
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="lesapplication.blogspot.com"
android:textColor="#A00000"
android:textStyle="bold|italic" />
<Spinner
android:id="@+id/myspinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/myspinner2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:spinnerMode="dialog" />
</LinearLayout>
package com.example.androidspinner;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.app.Activity;
public class MainActivity extends Activity {
String[] dayOfWeek = {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Spinner MySpinner1 = (Spinner)findViewById(R.id.myspinner1);
ArrayAdapter<String> myAdapter1 = new
ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, dayOfWeek);
myAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
MySpinner1.setAdapter(myAdapter1);
Spinner MySpinner2 = (Spinner)findViewById(R.id.myspinner2);
ArrayAdapter<String> myAdapter2 = new
ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, dayOfWeek);
myAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
MySpinner2.setAdapter(myAdapter2);
}
}
0 Response to "android:spinnerMode="dialog""
Posting Komentar