1

通常、ListViewを使用して、画像とテキストをListViewアイテムに追加するのは簡単です。カスタムアダプタを使用して、アダプタとsetListAdapter(アダプタ)を作成します。

ImageViewと同じリストを含むFragmentアプリを作成したいと思います。例を検索しましたが、画像のあるものは見つかりませんでした。誰かが私に例を教えてくれませんか?それがどのように行われるかを見ることができますか?

それはレイアウトランドXMLで行われますか?たとえば、次のxmlを使用してそれをどのように宣言しますか。

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent" android:layout_height="match_parent">

    <fragment class="com.demo.android.FragmentLayout$ArticleFragment"
            android:id="@+id/article" android:layout_weight="1"
            android:layout_width="0px" android:layout_height="match_parent" />

    <FrameLayout android:id="@+id/details" android:layout_weight="1"
            android:layout_width="0px" android:layout_height="match_parent"
            android:background="?android:attr/detailsElementBackground" />

</LinearLayout>
4

1 に答える 1

3

extendsFragmentまたはのクラスを作成してからListFragment、 your を含むレイアウトをインフレートし、 yourListViewを設定するだけAdapterです。

ListFragment

public class Example extends ListFragment {

// Adapter
private YourListAdapter mAdapter;

// ListView
private ListView mListView;

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // Adapter
    mListView.setAdapter(mAdapter);
    super.onActivityCreated(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.listview, container, false);
    mListView = (ListView)view.findViewById(android.R.id.list);
    return view;
    }
}
于 2012-04-22T01:22:52.807 に答える