android - Error: Change visibility of ''title'' to 'default' or Replace Bookinfo.title with getter -
i'm getting error on within fragment on bookinfo.title, bookinfo.author , book.isbn variables. have no thought why. documentation gives me error when trying right it. bookinf, has class consists of getters , setters. i'm getting error on word fragment in class bookdetailsfragment. error says add together @suppresslint 'newapi' bookdetailsfragment. help appreciated thanks.
here's code bookdetailsfragment:
import android.app.fragment; public class bookdetailsfragment extends fragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { //view view = inflater.inflate(r.layout.book_details, container, false); view view = inflater.inflate(r.layout.book_details, null); system.out.println("bookdetailsactivity executed"); //defines textviews in r.layout.book_details textview bktitle = (textview)view.findviewbyid(r.id.booktitle); textview bkauth = (textview)view.findviewbyid(r.id.bookauthor); textview bkisbn = (textview)view.findviewbyid(r.id.bookisbn); //retrieve bundle object passed buyfragtab bundle b = getarguments(); //getting item's clicked position , setting corresponding details bktitle.settext("title: " + bookinfo.title[b.getint("position")]); bkauth.settext("author: " + bookinfo.author[b.getint("position")]); bkisbn.settext("isbn: " + bookinfo.isbn[b.getint("position")]); homecoming view; } }
here's bookinfo class code:
package com.skipster.bookbarter; public class bookinfo { private string title; private string author; private string isbn; public bookinfo(string title, string author, string isbn) { this.title = title; this.author = author; this.isbn = isbn; // todo auto-generated constructor stub } public string gettitle() { homecoming title; } public void settitle(string title) { this.title = title; } public string getauthor() { homecoming author; } public void setauthor(string author) { this.author = author; } public string getisbn() { homecoming isbn; } public void setisbn(string isbn) { this.isbn = isbn; } //returns previous variables programme made phone call @override public string tostring() { homecoming title + " " + author + " " + isbn; } }
here's code bookdetailsactivity:
import android.os.bundle; import android.app.activity; import android.app.fragmentmanager; import android.app.fragmenttransaction; public class bookdetailsactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //setting layout activity setcontentview(r.layout.book_details_activity_layout); //get fragment manager fragment related operations fragmentmanager fm = getfragmentmanager(); //get fragment transaction object, can add, move or replace fragmnt fragmenttransaction ft = fm.begintransaction(); //instantiating fragment bookdetailsfragment bookdetailsfragment detailsfragment = new bookdetailsfragment(); //creating bundle object pass info (clicked item's position) //from activity fragment bundle b = new bundle(); //setting info bundle object intent b.putint("position", getintent().getintextra("position", 0)); system.out.println("the bundle passed" + b); //setting bundle object fragment detailsfragment.setarguments(b); //adding fragment fragment transaction ft.add(r.id.book_details_fragment_container, detailsfragment); //add fragment transaction backstack ft.addtobackstack(null); //executing transaction ft.commit(); } }
here's code onclicklistener starts intent:
booklv.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id){ string selecttitle, selectauthor, selectisbn = null; //when item clicked, show it's detailed view bookinfo bkrecs = (bookinfo)parent.getitematposition(position); //creating intent object start bookdetailsactivity intent bkintent = new intent("com.skipster.bookbarter.bookdetailsactivity"); //setting info (the clicked item's position intent bkintent.putextra("position", position); system.out.println("data loaded intent"); //start activity startactivity(bkintent); system.out.println("intent activity started"); } });
fragment class added in api 11. looks minsdk version older this. if want utilize fragments in older sdk, should utilize back upwards library, gives back upwards fragments..
for back upwards library refer : http://developer.android.com/tools/extras/support-library.html
android android-intent visibility fragment
No comments:
Post a Comment