Android资源配置arrays.xml的适配器Adapter
在res\valuse下创建一个数组资源的xml文件:arrays.xml
布局文件:activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/list_test"
android:entries="@array/myarray"
android:layout_gravity="center_horizontal" />
</LinearLayout>
展示视图控制文件:MainActivity
package run.yang.com.adapterdemo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
res\valuse下创建一个数组:arrays.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="myarray">
<item>语文</item>
<item>数学</item>
<item>英语</item>
</string-array>
</resources>
本文参考:
http://blog.csdn.net/coder_pig/article/details/48157807