0

Here is my code:

public class MenuActivity extends AppCompatActivity {
ListView listview;
ArrayAdapter adapter;
ArrayList<String> mylist;
String name;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_menu);

    listview = (ListView) findViewById(R.id.listview);
    mylist = new ArrayList<>();

    parseDataFetch();


}

public void parseDataFetch()
{
    if (FragmentA.item == "first") {

        ParseQuery<ParseObject> query = ParseQuery.getQuery("menu");
        query.whereEqualTo("type", "testRow");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> nameList, ParseException e)
            {
                if (e == null) {
                    for (ParseObject object : nameList) {
                         name = object.getString("itemName");
                        mylist.add(name);
                        adapter = new ArrayAdapter<>(MenuActivity.this, R.layout.activity_menu, mylist);
                    }
                    listview.setAdapter(adapter);
                } else {
                    Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
                    e.printStackTrace();
                }
            }
        });
    }
}
}

Only text is displayed but no images are being displayed, and its not working..

Please help, what is the problem with it as there are no errors generated.

sclv
  • 38,665
  • 7
  • 99
  • 204
  • try checking your response is coming or not, May be your response is null – N J Mar 18 '16 at 05:09
  • 1
    Where you setting up the image from response ? I can only see item name – Jay Rathod Mar 18 '16 at 05:10
  • Please set the adapter initialization outside the loop............. adapter = new ArrayAdapter<>(MenuActivity.this, R.layout.activity_menu, mylist); –  Mar 18 '16 at 05:15
  • Possible duplicate of [How do I compare strings in Java?](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) – OneCricketeer Mar 18 '16 at 05:35

1 Answers1

0

Other than the fact you are using == to compare strings...

Move this to onCreate

adapter = new ArrayAdapter<>(MenuActivity.this, R.layout.activity_menu, mylist);
listview.setAdapter(adapter);

Inside the loop, simply do

adapter.add(name);
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • i did that..its still not fetching data.. showing invalid session token exception.. i dropped the class and recreated it the problem still persists..i removed the string comparison line too by the way it didn't help.. – Anumita Purohit Mar 18 '16 at 08:23
  • That's a Parse Server error. I suggest you check your API key and Application ID values – OneCricketeer Mar 18 '16 at 08:31