2013-12-13 49 views
0

我有一個列表視圖,我正在更新消息,就像android收件箱消息我想保持列表視圖項目突出顯示,直到它被打開或單擊一次,我的代碼用於填充列表視圖是:保持列表視圖項目突出顯示,直到它被點擊一次

List<Message> values = datasource.getAllMessages(ch); 
     Collections.reverse(values); 
     ArrayAdapter<Message> adapter = new ArrayAdapter<Message>(getActivity(), android.R.layout.simple_list_item_1, values); 
     setListAdapter(adapter); 

功能getAllMessages正從數據庫中的值,以填充列表, 在此先感謝!

回答

0

您將需要通過擴展一個ArrayAdapter類來實現,要創建一個自定義適配器:

private class Adapter extends ArrayAdapter<String> 
{ 
    public Adapter(Context context, int resource, int textViewResourceId, String[] strings) 
    { 
     super(context, resource, textViewResourceId, strings); 
    } 

    public View getView(int position, View convertView, ViewGroup viewGroup) 
    { 
     View view = getLayoutInflater().inflate(R.layout.row_layout, null); 
     ....... 
     //do the logic of highlighting each row 

     return view 
    } 
相關問題