0
좋은 하루, 배열 어댑터의 목록 뷰에있는 텍스트보기 항목의 상태를 표시하려고합니다. 나는 listview의 항목을 성공적으로 저장할 수 있지만 listview가 다시 채워질 때 다시 표시 할 수는 없습니다.ArrayAdapter에서 목록보기에 취소 선 텍스트 상태를 저장하십시오. Android
onitemclick :
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String mytext = ((TextView)view).getText().toString();
TextView text = (TextView)view.findViewById(android.R.id.text1);
text.setText(mytext);
text.setPaintFlags(text.getPaintFlags()| Paint.STRIKE_THRU_TEXT_FLAG);
crossed_text.add(text.getText().toString()); // this is an Arraylist to store striked texts
}
및 채우기 목록보기 : 내가 다시 목록보기를 채우는 주를 통해이 타격을받을 수 있나요 어떻게
// i tried this
dialog = new Dialog(this);
LayoutInflater my_inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View checklistView = my_inflater.inflate(R.layout.check_list,null, false);
dialog.setContentView(checklistView);
dialog.setCancelable(true);
ListView list = (ListView)dialog.findViewById(R.id.listview_id);
TextView text = (TextView)list.findViewById(android.R.id.text1);
list.setOnItemClickListener(this);
list.setOnItemLongClickListener(this);
my_CheckList_Adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,data);
for(int i = 0; i < my_CheckList_Adapter.getCount(); i++){
TextView childtext = (TextView)list.getChildAt(i); // getting null value here
//childtext = (TextView)my_CheckList_Adapter.getItem(i).toString();
if(crossed_text.contains(childtext.getText().toString())){
childtext.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
}
}
list.setAdapter(my_CheckList_Adapter);
.. 감사
감사합니다. 이 줄에서 자식 텍스트의 null 값을 얻는 중입니다. TextView childtext = (TextView) list.getChildAt (i); 어떤 아이디어? – irobotxxx
list.setAdapter (my_CheckList_Adapter); for 루프 전에 설정하십시오. –
여기 ArrayAdapter http://sirinsevinc.wordpress.com/2010/05/11/109/를 사용하는 방법에 대한 좋은 기사가 있거나이 사이트의 어댑터에 대한 정보도 많이 있습니다 :) –