2013-02-18 44 views
0

我需要我的android应用程序的帮助。我需要在listview中自定义项目。我的应用程序使用片段。我不知道如何实现list_item.xml到我的代码。在android listview中设计一行

KartyListFragment.java

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
     Bundle savedInstanceState) { 
    View view = inflater.inflate(R.layout.karty_list, container, false); 
    return view; 
} 

karty_list.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="vertical" > 

<ListView 
    android:id="@android:id/list" 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    android:visibility="gone" /> 

<TextView 
    android:id="@android:id/empty" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:text="@string/prazdna_db" 
    android:textColor="#f00" 
    android:visibility="visible" /> 

</LinearLayout> 

我想在list_item.xml设计一个行,但我不知道怎么样。

回答

0

here你可以找到一个很好的教程,以建立您的列表视图。我认为这将是对你有帮助。

0

Jus创建您想要的布局,并将其传递给列表适配器作为要膨胀的视图。例如,使用SimpleAdapter

mAdapter = new SimpleAdapter(context, list, R.layout.my_custom_list_item, from, to); 
mListView.setAdapter(myAdapter);