Я новичок в Java и программировании в целом. И я пытался получить набор результатов от JSON, который был добавлен в простой адаптер для загрузки данных в TextView, содержащихся в RelativeLayout. Ссылка или любая помощь в правильном направлении были бы высоко оценены, спасибо в Advance. С уважением.Лучший способ привязки данных от AdapterView к RelativeLayout
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into RelativeLayout
* */
AdapterView adapter = new AdapterView(
AllProductsActivity.this, productsview,
R.layout.sample_view, new String[] { TAG_PID,
TAG_NAME},
new int[] { R.id.pid, R.id.name });
// updating View view
setAdapter(adapter);
}
});
}
}
}
Вот посмотрите на мой XML файл
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sample_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/pid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/name"
android:layout_below="@+id/name"
android:layout_marginTop="88dp"
android:text="Product ID"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="35dp"
android:layout_marginTop="24dp"
android:text="Product Name"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>