2012-04-22 3 views
1

나는 SimpleAdapter을리스트 어댑터로 사용하여 ListActivity을 확장하는 클래스가 있습니다. 내 코드는 다음과 같습니다.listview의 버튼 - android

public class ListOfFirms extends ListActivity { 

Intent extras; 
int time; 
String km; 
ArrayList<String> firms = new ArrayList<String>(); 
SimpleAdapter adapter; 
static final ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>(); 





    @Override 
    public void onCreate(Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 
     setContentView(R.layout.firms); 


     extras = getIntent(); 

     time = extras.getIntExtra("time", 0); 
     km = extras.getStringExtra("km"); 

     adapter = new SimpleAdapter(
       this, list, R.layout.taxi_custom, 
       new String[] {"name","price"}, 
       new int[] {R.id.taxi_name,R.id.taxi_price}); 

     initializeFirm(); 
     setListAdapter(adapter); 
    } 

제 질문은 목록의 각 요소에 단추를 추가하는 방법입니다. 단추는 오른쪽으로 이동해야합니다. 내 목록에 클래스 Firm의 개체가 포함되어 있습니다. 사용자가이 단추를 누르면 목록에서 어떤 개체를 가져올 지 어떻게 알 수 있습니까?

답변

1

here :-) 나중에 어차피 언젠가는해야 할 수있는 뭔가가 예입니다 사용자 지정 목록보기의 .... 당신에게 을

사용하여 사용자 정의 어댑터를 도와

listview.setAdapter(adapter); 
을 설정할 수있는
1

BaseAdapter를 확장하는 CustomAdapter를 작성해야합니다.

0

단추 대신 OnTouchListener 및 OnLongClickListener를 사용할 수 있으면 구현하기가 조금 더 쉽습니다. 또한 항목을 선택하기 만하면 표준 내장 안드로이드 메커니즘을 사용하는 것이 더 쉽습니다.

당신은 정말 당신이 Gaurav 아가 왈 제안처럼해야 할 각 목록 항목의 버튼 ...해야하는 경우에만 - 당신이

관련 문제