2010-12-31 4 views
0
I have designed a custom listview. In that view i have one textview and two edittext fields. when i am clicking on the individual rows in listview that perform another activity(i.e another page will open). But i cannot perform onclick action on my listview. 

나는 코드를 작성했지만 작동하지 않습니다. 나는 아래 코드를 보여 주었다.listview에서 onclick 액션을 수행하려면 어떻게해야합니까?

public void onCreate(Bundle savedInstanceState){ 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.sharefolioedit); 

     getList(); 
      lv.setAdapter(new EfficientAdapter(this)); 
      lv = getListView(); 
    lv.setClickable(true); 
      lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
     public void onItemClick(AdapterView<?> parentView, View childView, 
     int position, long id) { 
     Intent intent = new Intent(CategoryList.this,AddSubCategoryList.class); 
     startActivity(intent); 

     } 

     } 
+0

당신이'}'을 누락? 나는 3 개의 오프닝 브래킷을보고 있지만 닫는 것은 2 개뿐입니다 ... – DrColossos

+0

그래서 일부 logcat 출력이 있습니까? 일부 Log.d ("Debug", "..") 항목을 코드에 추가하여 실행되는 줄과 실행되지 않는 줄을 확인하십시오. 나는 listviews onclick 일반적으로 좋은 작품을 말할 수 있습니다. – mad

답변

0

이 나를 위해 잘 작동 :

this.setListAdapter(new EfficientAdapter(this)); 
this.getListView().setOnItemClickListener (new AdapterView. OnItemClickListener () 
{ 
    public void onItemClick (AdapterView <?> aView, View v, int position, long id) 
    { 
     Intent intent = new Intent(CategoryList.this,AddSubCategoryList.class); 
     startActivity(intent); 
    } 
}); 
+0

하지만 위의 코드는 작동하지 않습니다. 즉, 목록보기를 클릭 할 수 없습니다. 목록보기는 onclick 액션에 지원되지 않습니다. – user552978

+0

일부 변수를 onItemClick() 메소드에 출력하고 LogCat 뷰를 확인하여 메소드 실행 여부를 확인하십시오. –

관련 문제