Help in getting String Array from arrays.xml file

来源:互联网 发布:淘宝买家怎么发优惠券 编辑:程序博客网 时间:2024/06/07 06:59

https://stackoverflow.com/questions/2453989/help-in-getting-string-array-from-arrays-xml-file


import android.app.ListActivity;import android.os.Bundle;import android.widget.ArrayAdapter;public class Episode7 extends ListActivity {    String[] mTestArray;    /** Called when the activity is first created. */    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        // Create an ArrayAdapter that will contain all list items        ArrayAdapter<String> adapter;        mTestArray = getResources().getStringArray(R.array.testArray);            /* Assign the name array to that adapter and         also choose a simple layout for the list items */         adapter = new ArrayAdapter<String>(            this,            android.R.layout.simple_list_item_1,            mTestArray);        // Assign the adapter to this ListActivity        setListAdapter(adapter);    }}

end

原创粉丝点击