サーバーにリクエストを送信してjsonをダウンロードし、それをリストビューに解析するフラグメントがあります。どういうわけか、ビューに正しく到達できません。以下は私のアプリの一部です。これは、フラグメントを使用したリストビューの最初のタッチです。何らかの理由でフラグメントの使用のみを許可しているため、アダプターsetAdapter
として''ではなく''を選択しますsetListAdapter
myfragment.java
public class gallery extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View myFragmentView = inflater.inflate(R.layout.tab_frag2_layout,
container, false);
return myFragmentView;
}
public void onActivityCreated(Bundle savedInstanceState) {
.........
.........
.........
setAdapter(colorAdapter);
}
layout.tab_frag2_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/list_padding"
android:paddingRight="@dimen/list_padding"
android:tag="listf" />
</LinearLayout>
私の期待は使用しています
MyListView = (ListView)myFragmentView.findViewById(R.id.list);
ビューを取得するために、しかしそれはそのようには機能しません...今私は私のリストビューを取得して適用したいだけです
MyListView.setAdapter(colorAdapter)
それに
助けていただければ幸いです、ありがとう