Reputation: 145
I want to make an app with something like facebooks news feed it's going to be a text with an image below it that opens a new page, but I actually don't know what it's called so I can't search the internet for something that I don't know it's name, so if someone can tell me what is it called or how to make a news feed like facebook or a tutorial for the idea.
Upvotes: 5
Views: 26387
Reputation: 2796
This is basically a ListView
and ListAdapter
.
You have to alter the default ListView Layout as per your need.
As per your requirement, to achieve Facebook Layout, you can follow this resource link for help
http://www.androidhive.info/2014/06/android-facebook-like-custom-listview-feed-using-volley/
Upvotes: 12
Reputation: 31
I'll give you an option, and the first step. You can use requests via JSON to search the texts and images stored on a web served.
// DownloadJSON AsyncTask
private class DownloadJSON extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// Create a progressdialog
mProgressDialog = new ProgressDialog(MainActivity.this);
// Set progressdialog title
mProgressDialog.setTitle("Your app");
// Set progressdialog message
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
// Show progressdialog
mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
// Create an array
arraylist = new ArrayList<HashMap<String, String>>();
// Retrieve JSON Objects from the given URL address
jsonobject = JSONfunctions
.getJSONfromURL("YOUR_PATH_URL_CONECT.PHP");
try {
// Locate the array name in JSON
jsonarray = jsonobject.getJSONArray("value");
for (int i = 0; i < jsonarray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
jsonobject = jsonarray.getJSONObject(i);
// Retrive JSON Objects
map.put("thumbImage", jsonobject.getString("thumbImage"));
map.put("title", jsonobject.getString("title"));
// Set the JSON Objects into the array
arraylist.add(map);
}
} catch (JSONException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void args) {
// Locate the listview in listview_main.xml
listview = (ListView) findViewById(R.id.listview);
// Pass the results into ListViewAdapter.java
adapter = new ListViewAdapter(MainActivity.this, arraylist);
// Set the adapter to the ListView
listview.setAdapter(adapter);
// Close the progressdialog
mProgressDialog.dismiss();
return;
}
}
YOUR_PATH_URL_CONECT.PHP
echo '{"value":'.json_encode($yourArrayJsonObject).'}';
Now do the rest of creating adapters.
Upvotes: 1
Reputation: 2075
You have to read about a ListView
and ListAdapter
. Base your solution on them.
Upvotes: 6