java - Error when trying to create swipe view With tab bar -


i'm new andoid , trying create swipe view tab bar in android.

tabpageradapter

 import android.support.v4.app.fragment;  import android.support.v4.app.fragmentmanager;  import android.support.v4.app.fragmentstatepageradapter;             public class tabpageradapter extends fragmentstatepageradapter {                     public tabpageradapter(fragment      manager fm) {                     super(fm);                  @override             public fragment getitem(int i) {                 switch (i) {                     case 0:                          return new information();                     case 1:                          return new workforce();                     case 2:                          return new workdetailstable();                 }            return null;          }          @override         public int getcount() {             // todo auto-          generated method stub                 return 3; //no of tabs can give number of tabs             }           } 

information.java

     import android.app.datepickerdialog;             import android.app.dialog;             import android.app.fragmenttransaction;             import android.os.bundle;             import android.support.v4.app.fragmentactivity;             import android.view.layoutinflater;             import android.view.view;             import android.view.viewgroup;             import android.widget.arrayadapter;             import android.widget.datepicker;             import android.widget.edittext;             import android.widget.spinner;             import com.example.project.project.database.mydatabasehelper;             import android.support.v4.app.fragment;             import java.util.arraylist;             import java.util.calendar;             import java.util.list;               public class information extends fragment implements view.onclicklistener {                     private spinner spinner, spinner2, spinner3;                      private mydatabasehelper dbhelper;                     private com.example.project.project.api.infoapi ts;                     private static edittext txtdate;                     private datedialog dialog;                     private static string a;                     private static string b;                     private static string c;                     private static string date1;                      @override                     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {                         super.oncreate(savedinstancestate);                         view info = inflater.inflate(r.layout.information, container, false);                         dialog = new datedialog();                         txtdate = (edittext) info.findviewbyid(r.id.edittext5);                         txtdate.setonclicklistener(this);                          additemsonspinner();                         additemsonspinner2();                         return info;          }                       public void onclick(view arg0) {                         fragmenttransaction ft = getfragmentmanager().begintransaction();                         dialog.show(ft, "datepicker");                      }                       public void additemsonspinner() {                         spinner = (spinner) info.findviewbyid(r.id.spinner);                         list<string> list = new arraylist<string>();                         list.add("1");                         list.add("2");                         list.add("3");                          arrayadapter<string> adapter = new arrayadapter<string>(information.this, android.r.layout.simple_spinner_dropdown_item, list);                         adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item);                         spinner.setadapter(adapter);                       }                      public void additemsonspinner2() {                         spinner2 = (spinner) findviewbyid(r.id.spinner2);                         list<string> list = new arraylist<string>();                         list.add("sunny");                         list.add("cloudy");                          arrayadapter<string> adapter = new arrayadapter<string>(information.this, android.r.layout.simple_spinner_dropdown_item, list);                         adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item);                         spinner2.setadapter(adapter);                       }                        public static class datedialog extends android.app.dialogfragment implements datepickerdialog.ondatesetlistener {                         //  edittext txtdate;                         tab t;                           public datedialog() {                          }                           public dialog oncreatedialog(bundle savedinstancestate) {                              final calendar c = calendar.getinstance();                             int year = c.get(calendar.year);                             int month = c.get(calendar.month);                             int day = c.get(calendar.day_of_month);                             return new datepickerdialog(getactivity(), this, year, month, day);                         }                          public void ondateset(datepicker view, int year, int month, int day) {                             string date = day + "-" + (month + 1) + "-" + year;                             txtdate.  settext(date);                         date1 = txtdate.gettext().tostring();                         return;                      }                 }               } 

error

   information cannot converted fragment 

i refer type type mismatch: cannot convert registerfragment fragment doesn't help.

edited

 `android.support.v4.app.fragmenttransaction;` has imported both classes written unused import statement 

in information.java, onclick() has changed to

 public void onclick(view arg0) {         android.app.fragmenttransaction ft = getsupportfragmentmanager().begintransaction();         dialog.show(ft, "datepicker");      } 

you using v4 fragments , not fragmenttransaction:

 import android.app.fragmenttransaction; 

make sure consistently use v4 or app.

for v4 : getsupportfragmentmanager() non-v4 : getfragmentmanager()


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -