2012-09-14 62 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()

相关问题