【问题标题】:How to make a android interface with "football league table" style?如何制作具有“足球联赛表”风格的android界面?
【发布时间】:2011-10-09 04:04:34
【问题描述】:

我需要在我的应用上显示足球联赛表。像这样:http://www.fuencalientedelapalma.org/sitios/Fuencaliente/VF7/PublishingImages/Clasificacion.png

如您所见,我需要做某种 Android XML 布局,显示 9 列和 10 行,再加上一行作为列名。

我阅读了 android 开发者指南中关于 listview 的所有文档,但我找不到这样做的方法。而且我在谷歌上搜索,我找不到这样做的方法。

欢迎使用代码示例

谢谢

【问题讨论】:

  • 你真正面临的问题是什么

标签: android listview interface android-layout


【解决方案1】:

你可以像这样使用 listView,膨胀你自己的 listlayout :

maListViewPerso = (ListView) findViewById(R.id.listviewperso);


    ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();

    HashMap<String, String> map;


    for (int i = 0; i<statDB.getListStat().size(); i++){
        Stat stat= statDB.getListStat().get(i);
        listId.add(statDB.getListStat().get(i).getId()+"");
        String message = " Chiffre d'affaire : "+statDB.getListFinancier(stat.getId()+"").get(0).getCaBrut()+" euros";

        map = new HashMap<String, String>();
        titre 
        map.put("titre", stat.getDate());

        map.put("description", message);

        map.put("img", String.valueOf(R.drawable.icon_crisalid));
        map.put("stat_in",""+statDB.getListStat().get(i).getId());

        listItem.add(map);
    }


    statDB.close();


    SimpleAdapter mSchedule = new SimpleAdapter (this.getBaseContext(), listItem, R.layout.listview,
            new String[] {"img", "titre", "description"}, new int[] {R.id.img, R.id.titre, R.id.description});


    maListViewPerso.setAdapter(mSchedule);


    maListViewPerso.setOnItemClickListener(new OnItemClickListener() {
        @Override
        @SuppressWarnings("unchecked")
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {

            HashMap<String, String> map = (HashMap<String, String>) maListViewPerso.getItemAtPosition(position);
            Intent intent=new Intent().setClass(ListActivity.this, DetailActivity.class);
            intent.putExtra("stat_in", map.get("stat_in") );
            intent.putExtra("listId",listId);

            startActivity(intent);

        }
    });

这是我的列表视图代码:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>

<ImageView
    android:id="@+id/img"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"

    android:padding="20px"
    />

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:paddingLeft="10px"
    android:layout_weight="1"
    >

    <TextView android:id="@+id/titre"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:textSize="16px"
         android:textStyle="bold"
         android:textColor="@color/textcol"
         />

    <TextView android:id="@+id/description"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:textSize="12px"
         android:textColor="@color/textcol"
         android:paddingRight="10px"
         />

</LinearLayout>

这就是我检查列表视图的方式:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/backgroundcolor"
>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="fill_horizontal"

    android:paddingTop="5px"
    android:paddingBottom="5px"
    android:background="@drawable/bg2"
    >


    <TextView
        android:layout_weight="1"
        android:layout_height="fill_parent"
        android:layout_width="wrap_content" 
        /> 




</LinearLayout>


<ListView
    android:id="@+id/listviewperso"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
  />

你只需要调整列表视图。

【讨论】:

  • 我不知道如何处理与您的代码一起使用的 xml。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-21
  • 2021-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多