1
public class HomepageActivity extends ActionBarActivity {

protected List<ParseObject> mStatus;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_homepage);

    Parse.initialize(this, "dcAMNT7HVOmOw0JDMelkg5UDr388O3xSgICiSK3N", "1aHIAldsUScxlbkWGkoyvHoHWM9YEtpTb6QIijrb");

    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser != null) {
        // show user the homepage status
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Status");
        query.whereEqualTo("playerName", "Dan Stemkoski");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> status, ParseException e) {
                if (e == null) {
                    //success
                    mStatus = status;
                    StatusAdapter adapter = new     StatusAdapter(getListView().getContext(),mStatus);
                    setListadapter(adapter);
                } else {
                    //there was a problem, Alert user

                }
            }
        });

I am stuck because I need a list activity and I need to use a List adapter but I am using my HomepageActiviy extends ActionBarActivity. The only way it works is if I change the extends to List Activity but then my action bar with my settings wont show on the top only on the button when I press the left button on my s4.

2 Answers2

1

Why complicate things, you can leave it extends ActionBarActivity and use a ListView widget in your xml layout file. as easy as it sounds.

Also: you can't use getListView and setListadapter unless your are extending ListActivity which in your case you cannot do

tips:

http://developer.android.com/guide/topics/ui/layout/listview.html

Custom Adapter for List View

http://androidexample.com/Create_A_Simple_Listview_-_Android_Example/index.php?view=article_discription&aid=65&aaid=90

or just google anything related to listview

Community
  • 1
  • 1
TootsieRockNRoll
  • 3,218
  • 2
  • 25
  • 50
  • I have a widget already. But I am having the same erros. – Eduard Castellano May 13 '15 at 22:55
  • you can't use `getListView` and `setListadapter` unless your are extending `ListActivity` which you are not doing and you wont do, this is why I posted some links, you should preferably learn more about `ListView`, best of luck ! – TootsieRockNRoll May 13 '15 at 22:58
  • I know I can't that is why I am asking for advice. I read the three links you sent me and I still can't find the solution. I don't want to say the id's that I want to show in the ListView. All the examples are doing that. My application is a Status Updater, so there is no exact id's. I just have one Id which is defined as @android:id/list. – Eduard Castellano May 13 '15 at 23:11
0

Maybe this will help

public class HomepageActivity extends ActionBarActivity {
    private ListView lv; // Add a reference to your listview
    protected List<ParseObject> mStatus;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_homepage);
        lv = (ListView) findViewById(R.id.list); // Initialize your listview by pointing it to the correct listview in the layout file
        Parse.initialize(this, "dcAMNT7HVOmOw0JDMelkg5UDr388O3xSgICiSK3N", "1aHIAldsUScxlbkWGkoyvHoHWM9YEtpTb6QIijrb");

        ParseUser currentUser = ParseUser.getCurrentUser();
        if (currentUser != null) {
            // show user the homepage status
            ParseQuery<ParseObject> query = ParseQuery.getQuery("Status");
            query.whereEqualTo("playerName", "Dan Stemkoski");
            query.findInBackground(new FindCallback<ParseObject>() {
                public void done(List<ParseObject> status, ParseException e) {
                    if (e == null) {
                        //success
                        mStatus = status;
                        StatusAdapter adapter = new StatusAdapter(HomepageActivity.this ,mStatus); // Use the activity's context as the first parameter
                        lv.setAdapter(adapter); // Populate you listview here
                    } else {
                        //there was a problem, Alert user

                    }
                }
            });

Make sure the <ListView> tag in the activity_homepage layout has an id attribute like this android:id="@+id/list"

All the best :)

Narayan Acharya
  • 1,459
  • 1
  • 18
  • 33