I am developing Android application where I want to display the json format text and image retrieved from web service in horizontal list view. I am storing json formated data into ArrayList
The first thing is how to display a horizontal ListView. I want to recommend you use RecyclerView
for smoother listView display. So how to display recyclerView in Horizontal? This is my tutorial step by step.
First, in xml file should be like this:
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:scrollbars="vertical" />
Second, in the Activity's onCreate
should be like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerViewItem = (RecyclerView) findViewById(R.id.recyclerView);
LinearLayoutManager itemslayoutManager = new LinearLayoutManager(getApplicationContext());
itemslayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
recyclerViewItem.setLayoutManager(itemslayoutManager);
SampleAdapter sampleAdapter = new SampleAdapter(List<SampleData>);
recyclerViewItem.setAdapter(sampleAdapter);
return true;
}
To parse JSON you should use library called: Retrofit
instead of AsyncTask
try this:
Retrofit