0

嗨,我想在我的菜单列表上方添加一个仪表板,我做到了,但是当我在 AVD 上测试它时,仪表板正在为每个菜单循环

这是我的代码

法德.java:

public class Fard extends ListActivity 
{


public void onCreate(Bundle savedInstanceState) 
{
super.onCreate(savedInstanceState);


// storing string resources into Array
String[] fard_list = getResources().getStringArray(R.array.fardhu_list);

// Binding resources Array to ListAdapter
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.fard_item, R.id.label, fard_list));
ListView lv = getListView();

// listening to single list item on click
lv.setOnItemClickListener(new OnItemClickListener() {
  public void onItemClick(AdapterView<?> parent, View view,
      int position, long id) {

      // selected item 
      String product = ((TextView) view).getText().toString();

      // Launching new Activity on selecting single List Item
      Intent i = new Intent(getApplicationContext(), SingleListItem.class);
      // sending data to new activity
      i.putExtra("product", product);
      startActivity(i);

  }
});
}

} // end class

fardu_list.xml(值)

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="fardhu_list">
    <item>Subuh</item>
    <item>Dzuhur</item>
    <item>Ashar</item>
    <item>Maghrib</item>
    <item>Isya</item>
    <item>Jum at</item>
</string-array>
</resources>

fard_item.xml(布局)

<?xml version="1.0" encoding="utf-8"?>
<!--  Single List Item Design -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout style="@style/TitleBar">
    <ImageButton style="@style/TitleBarAction"
        android:contentDescription="@string/description_home"
        android:src="@drawable/title_home"
        android:onClick="onClickHome" />

    <ImageView style="@style/TitleBarSeparator" />
    <TextView style="@style/TitleBarText" />
    <ImageButton style="@style/TitleBarAction"
        android:contentDescription="@string/description_about"
        android:src="@drawable/title_about"
        android:onClick="onClickAbout" />
    <!-- ImageButton style="@style/TitleBarAction"
        android:contentDescription="@string/description_search"
        android:src="@drawable/title_search"
        android:onClick="onClickSearch" /> -->
</LinearLayout>
<TextView 
android:id="@+id/label"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dip"
    android:textSize="16dip"
    android:textStyle="bold" >

</TextView>
</LinearLayout>

我知道问题可能出在 fard_item.xml 我尝试以多种方式修改(布局)但仍然没有找到正确的方法,我怎样才能使仪表板不循环?

PS:我还是菜鸟。

4

0 回答 0