我有两种语言的两个文本文件。我需要我的代码从文本文件 1 和文本文件 2 中读取一行并将它们放入具有两个文本视图的列表视图中。我该怎么做?
我的代码在这里:
public class ListViewSoore extends ListActivity{
ArrayAdapter<String> adapter = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_view);
String itemsen[]=getResources().getStringArray(R.row.pa1);
adapter=new MyAdapter(this, android.R.layout.simple_list_item_1, R.id.textView1,itemsen);
setListAdapter(adapter);
}
private class MyAdapter extends ArrayAdapter<String> {
public MyAdapter(Context context, int resource, int textViewResourceId, String[] strings) {
super(context, resource, textViewResourceId, strings);
}
@Override
public View getView(int position,View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row=inflater.inflate(R.layout.list_item, parent, false);
String itemsen[]=getResources().getStringArray(R.row.pa1);
String itemsti[]=getResources().getStringArray(R.row.pa2);
TextView tven=(TextView) row.findViewById(R.id.textView1);
TextView tvti=(TextView) row.findViewById(R.id.textView2);
tven.setText(itemsen[position]);
tvti.setText(itemsti[position]);
return row;
}
}