2
I의 파일 및 클래스 다음사용자 지정 어댑터와 함께 GridView를 환경 설정 항목으로 사용하는 방법?
XML/preferences.xml로 :
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/characters_list">
<Preference
android:enabled="true"
android:key="characters_view"
android:layout="@layout/characters_view"
android:selectable="false"/>
</PreferenceCategory>
</PreferenceScreen>
레이아웃/character_view.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.xxx.widget.ExpandableHeightGridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/characters_gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnWidth="380dip"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"/>
</LinearLayout>
CharacterAdapter 클래스
class CharacterAdapter extends BaseAdapter {
@Override
public int getCount() {
return characters.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
HashMap<String, String> character = characters.get(position);
View view;
if (convertView == null) {
view = inflater.inflate(R.layout.characters_view_item, null);
} else {
view = convertView;
}
// ...
return view;
}
}
PreferenceActivity를에서 나는 그리드 항목보기 채울려고 : 단지 빈 기본 설정 항목을 :(볼 일이 발생
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.settings);
Preference characters = findPreference("characters_view");
View view = characters.getView(null, null);
ExpandableHeightGridView grid = (ExpandableHeightGridView) view.findViewById(R.id.characters_gridview);
grid.setExpanded(true);
grid.setAdapter(new CharacterAdapter(getCharacters()));
}
그러나 아무것도
은 사람이 환경 내에서의 GridView를 렌더링하는 방법을 알고 있습니까 목?
미리 감사드립니다.
ListView에 있지만 :
마지막
onCreate
방법 PreferenceActivity를 에 의지처럼 보인다 작동하지 않습니다 : ( –