JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » 違規輔導區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
話題被移動
該話題已被移動 - koji , 2013-05-30 09:40
如果您尚不清楚該話題被移動的原因,請參考論壇規則以及本版公告或者聯系本版版主。
本主題所含的標籤
作者 問題! listView使用textFilter(文字過濾)的問題...
Stillwildman





發文: 2
積分: 0
於 2013-05-22 19:47 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
各位高手大大們好,我先大略描述一下我的狀況!
{
我放了個eiditText
以及listView, 搭配了SimpleAdapter使用
並且把listVIew setTextFilterEnable
接著在editText上addTextChangedListener
}

SimpleAdapter可顯示兩行
如果兩行都是放text的話, 那我在editText中打字可以正常過濾!

BUT!!!!
如果在其中一行放imageView的話, 只要在editText裡一打字就立馬CRASH

以下我的程式碼....

這是可正常執行的 (simpleAdapter兩行都是text)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
private ListView PlanList;
private EditText typingText;
 
public void showSpot ()
{
  typingText = (EditText)findViewById(R.id.typingText);
  PlanList = (ListView)findViewById(R.id.PlanList);
    
  ArrayList<HashMap<String, Object>> itemList = new ArrayList<HashMap<String, Object>>();
    
  for (int i = 0; i < latList.length; i++)
  {
    HashMap<String, Object> planItems = new HashMap<String, Object>();
      
    planItems.put("spot", spotList[i]);
    planItems.put("day", queList[i]+ "-" + "Day:" + dayList[i]);
 
    /*
    if (flagList[i].equals("1"))
    {
      planItems.put("pic1", R.drawable.food_icon);
    } 
    */
 
    itemList.add(planItems);
  }
  final SimpleAdapter spotAdapter = new SimpleAdapter
          (Map2Activity.this, itemList, R.layout.my_list_layout02,
          new String[] {"spot", "day"},
          new int[] {R.id.my_textView1, R.id.my_textView2});
 
  PlanList.setAdapter(spotAdapter);
  PlanList.setTextFilterEnabled(true);
    
  typingText.addTextChangedListener(new TextWatcher() {
    public void onTextChanged(CharSequence s, int start, int before, int count) 
    {
      spotAdapter.getFilter().filter(s);
    }
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            public void afterTextChanged(Editable s) {}
  });
}


這是會出問題的! (simpleAdapter多了imageView)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
private ListView PlanList;
private EditText typingText;
 
public void showSpot ()
{
  typingText = (EditText)findViewById(R.id.typingText);
  PlanList = (ListView)findViewById(R.id.PlanList);
    
  ArrayList<HashMap<String, Object>> itemList = new ArrayList<HashMap<String, Object>>();
    
  for (int i = 0; i < latList.length; i++)
  {
    HashMap<String, Object> planItems = new HashMap<String, Object>();
      
    planItems.put("spot", spotList[i]);
    planItems.put("day", queList[i]+ "-" + "Day:" + dayList[i]);
 
    if (flagList[i].equals("1"))
    {
      planItems.put("pic1", R.drawable.food_icon);
    } 
 
    itemList.add(planItems);
  }
  final SimpleAdapter spotAdapter = new SimpleAdapter
          (Map2Activity.this, itemList, R.layout.my_list_layout02,
          new String[] {"spot",  "day",  "pic1"},
          new int[] {R.id.my_textView1, R.id.my_textView2, R.id.imageView1});
 
  PlanList.setAdapter(spotAdapter);
  PlanList.setTextFilterEnabled(true);
    
  typingText.addTextChangedListener(new TextWatcher() {
    public void onTextChanged(CharSequence s, int start, int before, int count) 
    {
      spotAdapter.getFilter().filter(s);
    }
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
            public void afterTextChanged(Editable s) {}
  });
}


imageView是可以順利顯示到listView之中的
....只是一執行textFilter的功能就會當機!

求高手們幫忙解答啊!!!

附上我的error log
http://paste.plurk.com/show/1550425


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
130 問題! listView使用textFilter(文字過濾)的問題... Stillwildman 3249 2013-05-22 19:47
» JWorld@TW »  違規輔導區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8