Я работаю над списком, я хочу, чтобы текст был видимым, который предоставляется ему в текстовом виде в XML-файле. Элементы списка, которые я добавил в списке, отображаются правильно (видимо), но не текст. Я хочу, чтобы текст, видимый, тоже нуждался в помощи для этого.Как сделать текст видимым в андроиде ListView
Xml файл
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="6dip"
android:paddingLeft="6dip"
android:text="Name:"
android:visibility="visible"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="@+id/gender"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="6dip"
android:paddingTop="6dip"
android:text="Gender:"
android:textColor="#FF00FF"
android:textSize="17sp"
android:textStyle="bold"
android:visibility="visible" />
</LinearLayout>
Java код: Ввод данных в адаптер
if (success == 1) {
products = json.getJSONArray(TAG_PRODUCTS);
for (int i = 0; i < products.length(); i++) {
JSONObject c = products.getJSONObject(i);
String id = c.getString(TAG_PID);
String name = c.getString(TAG_NAME);
String gender = c.getString(TAG_GENDER);
HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_ID, id);
map.put(TAG_NAME, name);
map.put(TAG_GENDER, gender);
productsList.add(map);
}
public void run() {
ListAdapter adapter = new SimpleAdapter(
AllPersonActivity.this, productsList,
R.layout.list_item, new String[] { TAG_ID,
TAG_NAME, TAG_GENDER},
new int[] { R.id.pid, R.id.name, R.id.gender });
// updating listview
setListAdapter(adapter);
}
});
Отправьте соответствующий код. –
вы можете добавить текст в текстовое окно, используя метод «append» – Raghunandan
, пожалуйста, отправьте код адаптера. – fasteque