2012-09-14 61 views
0

enter image description here每20秒

更改列表視圖的顏色是有可能改變的ListView顏色或背景顏色,每10個或15 seconds.I已經使用現有的代碼,這個列表視圖。在mycode中添加必要步驟的地方。我不希望每次選擇項目時更改用戶的顏色。如果用戶簡單地打開我的應用程序,並且自動更改背景顏色10秒。

mycode的:

public class MainActivity extends Activity { 
    private ListView lv; 
    private EditText et; 
    private String listview_array[] = { "ONE", "TWO", "THREE", "FOUR", "FIVE", 
    "SIX", "SEVEN", "EIGHT", "NINE", "TEN" }; 
    private ArrayList<String> array_sort= new ArrayList<String>(); 
    int textlength=0; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     lv = (ListView) findViewById(R.id.ListView01); 
     et = (EditText) findViewById(R.id.EditText01); 
     lv.setAdapter(new ArrayAdapter<String>(this, 
     android.R.layout.simple_list_item_1, listview_array)); 

     et.addTextChangedListener(new TextWatcher() 
     { 
     public void afterTextChanged(Editable s) 
     { 
                     // Abstract Method of TextWatcher Interface. 
     } 
     public void beforeTextChanged(CharSequence s, 
     int start, int count, int after) 
     { 
     // Abstract Method of TextWatcher Interface. 
     } 
     public void onTextChanged(CharSequence s, 
     int start, int before, int count) 
     { 
     textlength = et.getText().length(); 
     array_sort.clear(); 
     for (int i = 0; i < listview_array.length; i++) 
     { 
     if (textlength <= listview_array[i].length()) 
     { 
     if(et.getText().toString().equalsIgnoreCase(
     (String) 
     listview_array[i].subSequence(0, 
     textlength))) 
     { 
                                 array_sort.add(listview_array[i]); 
                             } 
                         } 
                     } 
     lv.setAdapter(new ArrayAdapter<String> 
     (MainActivity.this, 
     android.R.layout.simple_list_item_1, array_sort)); 
     } 
     }); 

    } 
+0

它可以使用自定義適配器...... – Shiva

回答

1
在你與充氣文本視圖的customview變色的getview()

。 並且每次需要時使用notifydatasetchanged()

相關問題