您的位置:首页 > 移动开发 > Android开发

ArrayAdapter简单适配器用法Android

2016-05-10 23:10 573 查看
public class MainActivity extends Activity {

private ListView listViewMain;
String[] totalList = null;//new String[]{"文本1","文本2","文本3","文本4","文本5"};
@Override
protected void onCreate(Bundle savedInstanceState) {
totalList = getResources().getStringArray(R.array.userName);

super.onCreate(savedInstanceState);
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.select_dialog_item, totalList);
setContentView(R.layout.activity_main);
listViewMain = (ListView) findViewById(R.id.listView_Main);

listViewMain.setAdapter(adapter);
}
}
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

android:id="@+id/listView_Main"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: