나는 안드로이드에서 간단한 응용 프로그램을 개발 중입니다. 나는 목록으로 표시하고 싶은 카테고리의리스트를 가지고있다. (그리고 이것은 멀리 떨어져있다.) 클릭 할 때, 어떤 함수로 다른 활동을 시작한다. ... 음, 상황 :사용자 정의 어댑터를 사용하여 listView에서 어느 값으로 이동해야합니까?
List<categorie> values = datasource.getAllCategorie();
// Use the SimpleCursorAdapter to show the
// elements in a ListView
ArrayAdapter<categorie> adapter = new ArrayAdapter<categorie>(this,
R.layout.single_list_item, values);
setListAdapter(adapter);
여기에 데이터 소스에서 I 선언 어디 getAllCategorie된다 :
내 single_list_item.xml : 나는 어댑터와 레이아웃을 호출 할 경우
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- Name Label -->
<TextView android:id="@+id/category_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:textColor="#43bd00"/>
<!-- Description Label -->
</LinearLayout>
여기에 주요 활동으로는
마지막으로 categorie.class: 나는 응용 프로그램을 실행하면 목록보기를 시작하는 동안
public class categorie {
private long id;
private String nome;
private long preferita;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public long getPreferita() {
return preferita;
}
public void setPreferita(long preferita) {
this.preferita = preferita;
}
// Will be used by the ArrayAdapter in the ListView
@Override
public String toString() {
return nome;
}
}
는 현재, 그것은 정지
, 그것은 완전히 비어 있습니다. 이름, ID 또는 "좋아요"(categorie.class에서 Preferita를 가져오고 설정)와 같은 각 범주 요소를 어디에 둘 것인지 지정하고 싶습니다.ArrayAdapter<categorie> adapter = new ArrayAdapter<categorie>(this,
android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);
모든 이유 OK 기본 레이아웃을 사용하고 있습니다 ... 마술 확인했다 : 내가 시작했을 때
는 어댑터 부분입니까? 다시, 어디로 가는지 어디에서 지정해야합니까?
미리 감사드립니다.