android - I can't use ListView when I am extending my class to ActionBarActivity. I can only access ListView when I extend to ListActivity. Any -


my activity: showing me 2 errors "required: android.widget.listview" imported listview widget activity dont understand what's issue.

package com.example.test.test;  import android.content.intent; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.widget.listview;  import com.parse.findcallback; import com.parse.parse; import com.parse.parseexception; import com.parse.parseobject; import com.parse.parsequery; import com.parse.parseuser;  import java.util.list;   public class homepageactivity extends actionbaractivity {  protected list<parseobject> mstatus;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_homepage);      final listview listview = findviewbyid(r.id.listview);      parse.initialize(this, "dcamnt7hvomow0jdmelkg5udr388o3xsgicisk3n", "1ahialdsuscxlbkwgkoyvhohwm9yetptb6qiijrb");      parseuser currentuser = parseuser.getcurrentuser();     if (currentuser != null) {         // show user homepage status         parsequery<parseobject> query = parsequery.getquery("status");         query.orderbydescending("createdat");         query.findinbackground(new findcallback<parseobject>() {             public void done(list<parseobject> status, parseexception e) {                 if (e == null) {                     //success                     mstatus = status;                     statusadapter adapter = new statusadapter(getapplicationcontext(), mstatus);                     listview.setadapter(adapter);                 } else {                     //there problem, alert user                  }             }         });      } else {         // show login screen         intent takeusertologinscreen = new intent(homepageactivity.this, loginactivity.class);         startactivity(takeusertologinscreen);     }  }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.menu_main, menu);     return true; }  @override public boolean onoptionsitemselected(menuitem item) {     // handle action bar item clicks here. action bar     // automatically handle clicks on home/up button, long     // specify parent activity in androidmanifest.xml.     int id = item.getitemid();     switch (id) {         case r.id.updatestatus:             //take user update status activity              intent intent = new intent(this, updatestatusactivity.class);             startactivity(intent);              break;          case r.id.logoutuser:             //log out user             parseuser.logout();              //take user login screen             intent takeusertologin = new intent(this, loginactivity.class);             startactivity(takeusertologin);              break;     }     return super.onoptionsitemselected(item);  } } 

my layout changed .android @+id...

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity">  <listview     android:id="@+id/listview"     android:layout_width="match_parent"     android:layout_height="match_parent">  </listview>  </relativelayout> 

it's because code uses default listview implementation using listactivity. need create custom listview this..

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity">  <listview android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent">  </listview>  </relativelayout> 

and activity...

@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_homepage);   listview listview = (listview)findviewbyid(r.id.list);  parse.initialize(this, "dcamnt7hvomow0jdmelkg5udr388o3xsgicisk3n",    "1ahialdsuscxlbkwgkoyvhohwm9yetptb6qiijrb");  parseuser currentuser = parseuser.getcurrentuser(); if (currentuser != null) {     // show user homepage status     parsequery<parseobject> query = parsequery.getquery("status");     query.orderbydescending("createdat");     query.findinbackground(new findcallback<parseobject>() {         public void done(list<parseobject> status, parseexception e) {             if (e == null) {                 //success                 mstatus = status;                 statusadapter adapter = new statusadapter(getapplicationcontext (), mstatus);                 listview.setadapter(adapter);             } else {                 //there problem, alert user              }         }     }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -