如何可以自定义网格视图的小区有两个TextView的,因为我想显示2个标签每一个细胞。
How can i customize a cell of Grid view with two textview, as i want to show 2 labels in each cell.
在我的任务,我期待的网格视图为表,它包含每个单元有两种不同的价值观。我曾尝试定制网格视图这个如下。
In my task, i am looking for the Grid View as a Table and it contains two various Values in each cell. i have Tried the Customized Grid view for this as follow.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button android:id="@+id/selectBtn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Select" android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:minWidth="200px" />
<GridView android:id="@+id/PhoneGrid"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:numColumns="auto_fit" android:verticalSpacing="10dp"
android:horizontalSpacing="10dp" android:columnWidth="90dp"
android:stretchMode="columnWidth" android:gravity="center"
android:layout_above="@id/selectBtn" />
</RelativeLayout>
和自定义布局,..
and the Custom layout is,..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:id="@+id/Name" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_centerInParent="true" />
<TextView android:id="@+id/Number" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
在此我需要显示在一个单一的GridView的姓名和电话号码。
In this i need to display the name and phone number in a single Gridview..
帮我做得到解决。
在此先感谢。
只要我已经使用多行处理字符串为\ N..
Simply i have used a String with Multiline Processing as "\n"..
就像你可以subsitude字符串如下:
Like you can subsitude the String as follows
String header=first_String_Variable+"\n"+second_String_Variable;
和使用适配器..定格
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, header);
gridHeader.setAdapter(adapter);