I have a list called statusses and among it the text needed which are the tweets called status. I want to set the status to listview.
public class MainActivity extends Activity {
ListView i;
List<Status> statusess;
ConfigurationBuilder cb;
twitter4j.Status status3;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
i = (ListView) findViewById(R.id.listView1);
new LongOperation().execute("");
}
private class LongOperation extends AsyncTask<String, Void, String> {
#Override
protected String doInBackground(String... params) {
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
String[] srch = new String[] {"Obama"};
ResponseList<User> users = null;
try {
users = twitter.lookupUsers(srch);
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (User user : users) {
System.out.println("Friend's Name " + user.getName()); // this print my friends name
if (user.getStatus() != null)
{
System.out.println("Friend timeline");
try {
statusess = twitter.getUserTimeline(user.getName());
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (twitter4j.Status status3 : statusess)
{
System.out.println(status3.getText());
}
}
}
return null;
}
#Override
protected void onPostExecute(String result) {
}
#Override
protected void onPreExecute() {
}
#Override
protected void onProgressUpdate(Void... values) {
}
}
now this System.out.println(status3.getText()); works 100%, the tweets are showing in the console. but how do I get them to the listview in onPostExecute?
I tried
i.setAdapter(new ArrayAdapter<twitter4j.Status>(MainActivity.this,
android.R.layout.simple_list_item_1, statusess));
But I get a lot of text not needed, I need only status3 which is text(tweet), this displays a lot of stuff like tweet id, retweet, followers, etc ..
I also tried this
#Override
protected void onPostExecute(String result) {
for (twitter4j.Status status3 : statusess)
{
i.setAdapter(new ArrayAdapter<statusess>(MainActivity.this,
android.R.layout.simple_list_item_1, status3.getText()));
}
}
but didn't work, a lot of red line xD
users = twitter.lookupUsers(srch);
This gives you a list of users. You are running a for-loop to iterate through the list, changing statuses on each iteration. When the for-loop ends, statuses holds the status list(returned by twitter.getUserTimeline(user.getName())) of the last user. Is this really what you want?
For example, you can display the user list that is returned using twitter.lookupUsers(srch), in the ListView. And, on a item click event, display the status list for that user.
Once you decide on the user for whom you need the status list, do the following:
// Declare an ArrayList with class scope
ArrayList<String> statusListTextOnly;
// Initialize it in doInBackground()
#Override
protected String doInBackground(String... params) {
....
....
statusListTextOnly = new ArrayList<String>();
// Initialize 'statuses' for the user that you have decided on
statusess = twitter.getUserTimeline(user.getName());
// Run a for-loop to fill 'statusListTextOnly'
// We will use 'statusListTextOnly' with the ArrayAdapter
for (twitter4j.Status status3 : statusess) {
statusListTextOnly.add(status3.getText());
}
}
// Initialize/reset ArrayAdapter
#Override
protected void onPostExecute(String result) {
i.setAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_list_item_1, statusListTextOnly));
}
The problem with your code lies here:
i.setAdapter(new ArrayAdapter<twitter4j.Status>(MainActivity.this,
android.R.layout.simple_list_item_1, statusess));
Objects passed to an ArrayAdapter are displayed using the toString() method. Now, toString() is mostly overriden for custom objects and serves the purpose of providing a meaningful description of the object itself. It can be overriden to provide literally any kind of information in a String format. In case of Status objects, toString() returns a bit more than what you need. So, we extract the relevant info using Status#getText() and store it in a separate ArrayList.
Your second attempt has problems as well:
#Override
protected void onPostExecute(String result) {
for (twitter4j.Status status3 : statusess) {
i.setAdapter(new ArrayAdapter<statusess>(MainActivity.this,
android.R.layout.simple_list_item_1, status3.getText()));
}
}
Here, you are setting the generic parameter of ArrayAdapter to a variable('statuses'): the generic parameter should be a class. Next, you pass a String as the last argument, whereas an ArrayAdapter's constructor can either take an array of objects, or an ArrayList. Third, you are creating a new instance of your ArrayAdapter and setting it to the ListView on each iteration of the for-loop. This is logically incorrect. You need one instance of an ArrayAdapter and you only need to set it once.
What else can you do:
Create a custom ArrayAdapter that affords new functionality, for example: showing of images along with text.
Dig into BaseAdapter: Highly customizable, all-purpose adapter.
package com.example.twitterdemo;
import java.util.List;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
public final class GetTimeLines {
*//**
* Usage: java twitter4j.examples.GetTimelines ID Password
* #param args String[]
*//*
public static void main(String[] args) {
Twitter unauthenticatedTwitter = new TwitterFactory()
.getInstance();
System.out.println("Showing public timeline.");
try {
List<Status> statuses = unauthenticatedTwitter
.getUserTimeline();
for (Status status : statuses) {
System.out.println(status.getUser().getName() + ":"
+ status.getText());
}
if (args.length < 2) {
System.out
.println("You need to specify TwitterID/Password combination to show UserTimelines.");
System.out
.println("Usage: java twitter4j.examples.GetTimelines ID Password");
System.exit(0);
}
// Other methods require authentication
Twitter twitter = new TwitterFactory().getInstance();
statuses = twitter.getUserTimeline();
System.out.println("------------------------------");
System.out.println("Showing " + args[0]
+ "'s friends timeline.");
for (Status status : statuses) {
System.out.println(status.getUser().getName() + ":"
+ status.getText());
}
statuses = twitter.getUserTimeline();
System.out.println("------------------------------");
System.out.println("Showing " + args[0] + "'s timeline.");
for (Status status : statuses) {
System.out.println(status.getUser().getName() + ":"
+ status.getText());
}
Status status = twitter.showStatus(81642112l);
System.out.println("------------------------------");
System.out.println("Showing " + status.getUser().getName()
+ "'s status updated at " + status.getCreatedAt());
System.out.println(status.getText());
System.exit(0);
} catch (TwitterException te) {
System.out.println("Failed to get timeline: "
+ te.getMessage());
System.exit(-1);
}
}
}
Related
I am calling rest API which gets access token from salesforce. after I make a rest call to get data from Salesforce and I'm successfully getting records. and all records are shown in android activity list view.
after that I call fragment but fragment view is not showing.
if I'm not making rest call then fragment show properly.
Here is the MainActivity class
public class MainActivity extends AppCompatActivity {
DrawerLayout dLayout;
private ArrayAdapter<String> listAdapter;
ProgressDialog progressDialog;
JSONTokener tokener;
String accessToken_, instanceURL_;
JSONArray finalResult;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setNavigationDrawer(); // call method
// button_save_account = (Button) findViewById(R.id.button_save_account);
accessToken_ = "00D7F000005oJve!ARUAQPJ8hMWibtO1flIPjZfzV4A__Kzj6wTjJ5XA_xE1zbqDs_0fOTZuxJFiLVxsFx_kNPxuNNK6c7yREtbxq4J7W1oWuUEs";
instanceURL_ = "https://harishgakhar40-dev-ed.my.salesforce.com";
// Create list adapter
listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new ArrayList<String>());
((ListView) findViewById(R.id.contacts_list)).setAdapter(listAdapter);
try {
MyAsyncTasks myAsyncTasks = new MyAsyncTasks();
myAsyncTasks.execute(accessToken_, instanceURL_).get();
} catch (Exception e) {
}
}
private void setNavigationDrawer() {
dLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // initiate a DrawerLayout
NavigationView navView = (NavigationView) findViewById(R.id.navigation); // initiate a Navigation View
navView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
#Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
Fragment frag = null; // create a Fragment Object
int itemId = menuItem.getItemId(); // get selected menu item's id
if (itemId == R.id.first) {
frag = new InsertRecords();
Bundle bundle = new Bundle();
bundle.putString("access token", accessToken_);
bundle.putString("instanc url", instanceURL_);
frag.setArguments(bundle);
} else if (itemId == R.id.second) {
Log.v("fragment second ---- ", "In Fragment Second ---- ");
frag = new SecondFragment();
} else if (itemId == R.id.third) {
frag = new ThirdFragment();
}
Toast.makeText(getApplicationContext(), menuItem.getTitle(), Toast.LENGTH_SHORT).show();
if (frag != null) {
Log.v("frag ---- ", "frag ------ " + frag);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Log.v("transaction ---- ", "transaction ------ " + frag);
transaction.replace(R.id.frame, frag); // replace a Fragment with Frame Layout
transaction.commit(); // commit the changes
dLayout.closeDrawers(); // close the all open Drawer Views
return true;
}
return false;
}
});
}
public class MyAsyncTasks extends AsyncTask<String, String, String> {
#Override
protected void onPreExecute() {
super.onPreExecute();
// display a progress dialog for good user experiance
progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Please Wait");
progressDialog.setCancelable(false);
progressDialog.setMessage("Loading...");
progressDialog.show();
}
#Override
protected String doInBackground(String... params) {
String accessToken = params[0];
String instanceURL = params[1];
// implement API in background and store the response in current variable
String result = "";
DefaultHttpClient client = new DefaultHttpClient();
String url = instanceURL + "/services/data/v20.0/query/?q=";
String soqlQuery = "Select Id, Name, BillingStreet, BillingCity, BillingState From Account Limit 10 ";
try {
url += URLEncoder.encode(soqlQuery, "UTF-8");
} catch (UnsupportedEncodingException e) {
}
HttpGet getRequest = new HttpGet(url);
getRequest.addHeader("Authorization", "OAuth " + accessToken);
Log.v("Token in doin ---- ", "accessToken ---- in doin ---- " + accessToken);
Log.v("instanceURL doin ---- ", "instanceURL ---- in doin ---- " + instanceURL);
try {
HttpResponse response = client.execute(getRequest);
result = EntityUtils.toString(response.getEntity());
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
#Override
protected void onPostExecute(String result) {
try {
progressDialog.dismiss();
// dismiss the progress dialog after receiving data from API
JSONObject object = (JSONObject) new JSONTokener(result).nextValue();
JSONArray records = object.getJSONArray("records");
// globalState.setAccountNames(new String[records.length()]);
// globalState.setAccounts(new JSONObject[records.length()]);
listAdapter.clear();
for (int i = 0; i < records.length(); i++) {
JSONObject record = (JSONObject) records.get(i);
String accountName = record.getString("Name");
Log.v("accountName---- ", "accountName ---- " + accountName);
listAdapter.add(accountName);
// globalState.getAccountNames()[i] = accountName;
//globalState.getAccounts()[i] = record;
}
} catch (Exception e) {
}
Log.d("data", result.toString());
}
}
}
You are blocking MainThread which is rendering UI.
To avoid this, android provides AsyncTask.
BUT make yourself and others working on your project favor and use Retrofit or other libraries. It will save you so much time and make your code cleaner.
Here you can find a good article.
If you really don't feel like using Retrofit, AsyncTask is an option too
You need to call your getAccountData function inside an AsyncTask. The implementation right now is blocking your UI thread, which created the problem I think.
public class GetAccountData implements AsyncTask<Void, Void, String> {
#Override
protected String doInBackground(Void... params) {
// Get account data here.
}
#Override
protected void onPostExecute(final String accountName) {
// Pass the accountName to the calling Activity here.
}
// Implement other methods if you need
}
If you are confused about how you can pass the data from your AsyncTask to your Activity, please consider looking into this answer here.
In the following code I search HighScore class for the best time results ordered by ascending.
So I'm getting list of best results.
What I having a difficulty is to add the name and the school name to of each time result to the list.(please see the attached images)
private class RemoteDataTask extends AsyncTask<Void, Void, Void> {
// Override this method to do custom remote calls
protected Void doInBackground(Void... params) {
// Gets the current list of bestTime in sorted order
ParseQuery query = new ParseQuery("TestsTopRecords");
query.orderByAscending("bestTime");
try {
results = query.find();
} catch (ParseException e) {
}
return null;
}
#Override
protected void onPreExecute() {
HighScoreTable.this.progressDialog = ProgressDialog.show(HighScoreTable.this, "",
"Loading...", true);
super.onPreExecute();
}
#Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
#Override
protected void onPostExecute(Void result) {
// Put the list of results into the list view
ArrayAdapter<Double> adapter = new ArrayAdapter<Double>(HighScoreTable.this,R.layout.todo_row);
for (ParseObject object : results) {
adapter.add((Double) object.get("bestTime"));
}
setListAdapter(adapter);
HighScoreTable.this.progressDialog.dismiss();
TextView empty = (TextView) findViewById(android.R.id.empty);
empty.setVisibility(View.VISIBLE);
}
}
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_high_score_table);
TextView empty = (TextView) findViewById(android.R.id.empty);
empty.setVisibility(View.INVISIBLE);
new RemoteDataTask().execute();
registerForContextMenu(getListView());
}
Here's probably the simplest hack to do this.
Use String instead of Double and do this
ArrayAdapter<String> adapter = new ArrayAdapter<String>(HighScoreTable.this,R.layout.todo_row);
for (ParseObject object : results) {
adapter.add((Double) object.get("bestTime") + " " + object.getString("Name") + " " + object.getString("SchoolAndCity"));
}
I'm trying to implement a facebook app according to the example in the facebook-android-sdk .
I'm changing it a little bit and I'm having a difficult about someting which is very basic.
I'm having my main activity which shows the facebook places near me.
thats the code at mainActivity.java
private void getFBPlaces()
{
fbObject.fetchPlaces();
// NOW I want to fill my listview with the results.....
// someting like
placesList = (ListView) findViewById(R.id.places_list);
placesList.setOnItemClickListener(Places.this);
placesList.setAdapter(new PlacesListAdapter(Places.this));
}
this is the relevant code from FBObject.java see the TODO
private void fetchPlaces() {
/*
* Source tag: fetch_places_tag
*/
Bundle params = new Bundle();
params.putString("type", "place");
try {
params.putString("center",
location.getString("latitude") + "," + location.getString("longitude"));
} catch (JSONException e) {
showToast("No places fetched.");
return;
}
params.putString("distance", "1000");
Utility.mAsyncRunner.request("search", params, new placesRequestListener());
}
/*
* Callback after places are fetched.
*/
public class placesRequestListener extends BaseRequestListener {
#Override
public void onComplete(final String response, final Object state) {
Log.d("Facebook-FbAPIs", "Got response: " + response);
dialog.dismiss();
try {
jsonArray = new JSONObject(response).getJSONArray("data");
if (jsonArray == null) {
showToast("Error: nearby places could not be fetched");
return;
}
} catch (JSONException e) {
showToast("Error: " + e.getMessage());
return;
}
mHandler.post(new Runnable() {
#Override
public void run() {
// TODO: I want to return the result to main activity
.....
}
});
}
got any idea?
thanks
The way I'd do this is passing the activity instance to the PlacesRequestListener and, in the complete callback, do something like "activity.findViewById(R.id.places_list)" to get the list. From here you can set the adapter.
Of course that the method needs to be running on the main thread in order to be able to manipulate the UI
You should consider using the new v3.0b of the Android SDK. In particular, it has a built-in place picker that will help accelerate what you are trying to do here.
You'll find it at http://developers.facebook.com/android
I have an AsyncTask which loads Tweets from Twitter.
I also have a PullToRefresh ListView... Whenever i pull to refresh it, the listview immediately clears and as soon as the data has been loaded, it's getting filled into the listview.
I have other ListViews in my App all with the same stuff (PullToRefresh and Async data loading...). On the other ListViews this does not happen. Only on the Twitter ListView. What am I doing wrong?
Here is my Code:
public class TwitterDownloader extends AsyncTask<Void, Void, String> {
final Handler mHandler = new Handler();
public TwitterDownloader() {
}
#Override
public void onPreExecute() {
super.onPreExecute();
}
#Override
protected String doInBackground(Void... params) {
twitter4j.Twitter twitter = new TwitterFactory().getInstance();
listTweets.clear();
List<twitter4j.Status> statuses = null;
try {
statuses = twitter.getUserTimeline(
MainActivity.TWITTER_USERNAME, new Paging(1, 50));
} catch (TwitterException e) {
e.printStackTrace();
Log.e(MainActivity.LOG_TAG, "TwitterException");
}
try {
for (twitter4j.Status status : statuses) {
listTweets.add(status.getText());
}
} catch (NullPointerException npe) {
}
return null;
}
#Override
public void onPostExecute(String unused) {
MyCustomAdapter myAdapter = new MyCustomAdapter(myContext,
R.layout.row_twitter, listTweets);
setListAdapter(myAdapter);
getListView().setTextFilterEnabled(true);
String lastUpdate = (new SimpleDateFormat(
"HH:mm")).format(new Date());
pullToRefreshView.onRefreshComplete();
pullToRefreshView.setLastUpdatedLabel(getString(R.string.last_updated) + ": "
+ lastUpdate);
}
I am not sure about this but in doInBackground method of AsyncTask, you are doing listTweets.clear();. After getting result, you are adding data to it. May be this is causing problems.
I finally fixed it by adding all my clear() statements right before I fill up my list again (which is inside a try catch).
So the new code inside my doInBackground method is:
try {
listTweets.clear();
listUsernames.clear();
listDates.clear();
listImageURLs.clear();
listURLsOfTweets.clear();
for (twitter4j.Status status : statuses) {
listTweets.add(status.getText());
listUsernames.add(status.getUser().getName());
listDates.add(android.text.format.DateFormat
.getDateFormat(getApplicationContext()).format(
status.getCreatedAt())
+ " "
+ android.text.format.DateFormat.getTimeFormat(
getApplicationContext()).format(
status.getCreatedAt()));
listImageURLs.add(status.getUser().getProfileImageURL()
.toString());
StringBuffer address = new StringBuffer();
address.append("http://twitter.com/#!/");
address.append(status.getUser().getScreenName());
address.append("/status/");
address.append(status.getId());
listURLsOfTweets.add(address.toString());
}
I am building one app having One list view showing the list of My favorites Fans. My list of Fans is this!
When i click on any item of this list then it show me complete profile of the concern Fan e.g., this
My Code is ->
public class FavouriteFansActivity extends ListActivity implements OnItemClickListener, OnLongClickListener {
ListView mFavFansListView;
JSONArray jArrayFavFans;//jArrayFavFans that contains jobjects of all fans. each jobj hv data of 1 unique fan!
JSONObject jFavFan_Data;//contain data of an indivisual fan
LazyAdapter adapter;
ArrayList<Object> favFansList;
ArrayList<String> mfavFansImgs;
ItemBean bean;
String favFans;
//String url="http://XXXXX/ManU/";//Live
String url="http://XXXXX/ManU/";//Local
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.on_favourite_fan_list);
prepareFavFanArrayLits();//method that prepare list of my favorite fans....
mFavFansListView = (ListView) findViewById(android.R.id.list);
adapter = new LazyAdapter(this, mfavFansImgs, favFansList);
mFavFansListView.setAdapter(adapter);
mFavFansListView.setOnItemClickListener(this);
mFavFansListView.setOnLongClickListener(this);
/** I am still not getting that when to call onPause(), onResume(), onRestart()... etc ??? */
}
/* .........onItemClick......... */
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
// TODO Auto-generated method stub
ItemBean bean = (ItemBean) adapter.getItem(position);
/**from here-> I am going to start one activity that show the complete profile of a
* particular Fan... According to the unique id received from clicking on ListItem!
*/
Intent in= new Intent(getParent(), FavFanProfile.class);
TabGroupActivity prnt = (TabGroupActivity) getParent();
Bundle fBundle= new Bundle();
fBundle.putString("fanId", bean.getUid());
in.putExtras(fBundle);
prnt.startChildActivity("FavFanProfile", in);
}
/* .........onLongClick......... */
#Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(FavouriteFansActivity.this, "To remove...Clk", Toast.LENGTH_SHORT).show();
return false;
}
/** Method used to prepare the List of Favorite Fans
* #author Rupesh */
public void prepareFavFanArrayLits() {
/* return me array containing data of all favFans */
Boolean mkFavFansList=false;
SharedPreferences favFansData = getSharedPreferences("jArrayFavFansPref", MODE_WORLD_WRITEABLE);
favFans=favFansData.getString("favFansData", "");
Log.i("FavFans_List->", "FavFans_DATA readed from prefs:"+favFans.toString());
if(!favFans.equals("")){
try {
mkFavFansList=true;
jArrayFavFans=new JSONArray(favFans);
favFansList = new ArrayList<Object>();
mfavFansImgs = new ArrayList<String>();
Log.i("fav_fansONfav", jArrayFavFans.toString());
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}else {
Log.i("else_favList_img", "list & image are initialized");
favFansList = new ArrayList<Object>();
mfavFansImgs = new ArrayList<String>();
}
// ++++++++
if(mkFavFansList){
try {
for (int i = 0; i < jArrayFavFans.length(); i++) {
// will return the data of each row fetched from JSONArray returned by location1.php
String data_of_each_user = jArrayFavFans.get(i).toString();
Log.i("Data Of User at index " + i + " is", data_of_each_user);
// I put the object at index "i" into JSONObject & retrieve data from name-value pair
jFavFan_Data = jArrayFavFans.getJSONObject(i);// data of User at index i
// in array
AddObjectToList(jFavFan_Data.getString("uniqid").toString(), jFavFan_Data.getString("name"),
jFavFan_Data.getString("distance"));
//Log.i("URL", url+"images/"+jFavFan_Data.get("uniqid").toString()+".png");
mfavFansImgs.add(url+"images/"+jFavFan_Data.get("uniqid").toString()+".png");
Log.i("IMG_URL", url+"images/"+jFavFan_Data.get("uniqid").toString()+".png");
String nm = jFavFan_Data.get("name").toString();
String uid = jFavFan_Data.get("uniqid").toString();
String dis = jFavFan_Data.get("distance").toString();
//System.out.println("Your Name: " + nm);
System.out.println("Your Unique Id: " + uid);
//System.out.println("Your Distance: " + dis);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
} else {
Log.i("NO_FAVORITE_FANS", "No Favorite Fans are added in favorites List!");
Toast.makeText(FavouriteFansActivity.this, "No Fans in Favorite List!", Toast.LENGTH_SHORT).show();
}
// ++++++++++
}
//**********************setting vales in bean*************************
public void AddObjectToList(String uid, String title, String desc) {
bean = new ItemBean();
bean.setUid(uid);
bean.setDescription(desc);
bean.setTitle(title);
favFansList.add(bean);
}
//***********************************************
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.i("favFansData_FavoriteFansActivity.java", "hi...on resume"+favFans);
prepareFavFanArrayLits();
setContentView(R.layout.on_favourite_fan_list);
mFavFansListView = (ListView) findViewById(android.R.id.list);
adapter = new LazyAdapter(this, mfavFansImgs, favFansList);
mFavFansListView.setAdapter(adapter);// come null pointer exception when no fan data is returned! hendle it...
mFavFansListView.setOnItemClickListener(this);
}
}
I stuck at the point -> That, how to remove one Item(one Fan) from this list(favorite_fans_list) ...???
I try to do something on onLongClick Listener but it doesn`t work.... I pleased to have any pointer or some sample which help me to overcome from this problem!!!
One way would be to modify the content in the adapter and then notify the listview has changed.
Your adapter holds an ArrayList for the data backing it.
You need to remove the object from the list. Then notify the adapter that the set has changed as follows.
favFansList.remove(index);
adapter.notifyDataSetChanged()