android.R.layout.simple_list_item_2..how如何给出第二项?

时间:2018-02-16 11:36:45

标签: android json

protected void onPostExecute(Exception result) {
     super.onPostExecute(result);
     ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this ,android.R.layout.simple_list_item_2,titles);
//I want also to give the dates beside titles but it is giving me error
    lvRss.setAdapter(adapter);
    progressDialog.dismiss();
}

我使用android.R.layout.simple_list_item_2来获取两个textView但是如何初始化第二个?

1 个答案:

答案 0 :(得分:0)

使用下面的ListAdapter或使用CustomAdpater

ListAdapter listAdapter = new SimpleCursorAdapter(
             this,
             android.R.layout.simple_list_item_2,
             mCursor,     
             new String[] {"", ""}, 
             new int[] {android.R.id.text1, android.R.id.text2}); 


setListAdapter(adapter);

希望它有所帮助!