0
사용자 정의 레이아웃으로 ListView를 만들려고했지만 지금까지 성공적으로 할 수 없었습니다. 나는 초보자이며 튜토리얼을 따라 해냈다. 내가 응용 프로그램을 시작하면ListView with Custom Adaptor [안드로이드]
//this is where I want the custom list items to be displayed.
//GroupAdapter is the constructor of the class in which I'm trying to make a custom adapter
stringArray = new String[10];
groupItemArrayAdapter = new GroupAdapter(this,stringArray);
groupListView = (ListView) findViewById(R.id.mainList);
groupListView.setAdapter(groupItemArrayAdapter);
//this is the code in GroupAdapter.java class
public class GroupAdapter extends ArrayAdapter{
private LayoutInflater inflater;
public GroupAdapter(Activity activity, String[] items){
super(activity,R.layout.group_view);
inflater=activity.getWindow().getLayoutInflater();
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
return inflater.inflate(R.layout.group_view,parent,false);
}
}
이 빈 화면이 나타납니다 이 내가 뭘하는지입니다. 처음에는 목록에 Android 기본 레이아웃을 사용했을 때 목록 항목이 표시되었지만 더 이상 표시되지 않았습니다 ... 내가 잘못하고있는 것을 이해하지 못합니다. 누구든지 도와 줄 수 있습니까? 여기
당신은 모든 코드를 대체 할 수 group_view.xml 파일<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="30dp" >
<TextView
android:id="@+id/gName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Group Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginRight="100dp"
android:textStyle="bold" />
<TextView
android:id="@+id/activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/signIn"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="5"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
</LinearLayout>
참조 http://www.vogella.com/tutorials/AndroidListView/article.html – gio
@ (버전 가장 간단한) 것 지오 이미 도움이 안된다 – leMS
@leMS는 레이아웃'layout.group_view'를 제공합니다 – gio