ArrayAdapter
android.R.layout.simple_list_item_1 文字樣式,上下間距適中
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] strGroup = {"字串1", "字串2", "字串3", "字串4", "字串5", "字串6"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(
this,
android.R.layout.simple_list_item_1,
strGroup);
ListView v = new ListView(this);
v.setAdapter(adapter);
setContentView(v);
}
}
android.R.layout.simple_list_item_1 文字樣式,上下間距較小
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] strGroup = {"字串1", "字串2", "字串3", "字串4", "字串5", "字串6"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(
this,
android.R.layout.simple_spinner_item,
strGroup);
ListView v = new ListView(this);
v.setAdapter(adapter);
setContentView(v);
}
}
android.R.layout.simple_list_item_1 文字樣式,上下間距較小,文字較大
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] strGroup = {"字串1", "字串2", "字串3", "字串4", "字串5", "字串6"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(
this,
android.R.layout.simple_gallery_item,
strGroup);
ListView v = new ListView(this);
v.setAdapter(adapter);
setContentView(v);
}
}
android.R.layout.simple_list_item_single_choice 單選樣式
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] strGroup = {"字串1", "字串2", "字串3", "字串4", "字串5", "字串6"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(
this,
android.R.layout.simple_list_item_single_choice,
strGroup);
ListView v = new ListView(this);
v.setAdapter(adapter);
setContentView(v);
}
}
android.R.layout.simple_list_item_multiple_choice 多選樣式
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] strGroup = {"字串1", "字串2", "字串3", "字串4", "字串5", "字串6"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(
this,
android.R.layout.simple_list_item_multiple_choice,
strGroup);
ListView v = new ListView(this);
v.setAdapter(adapter);
setContentView(v);
}