0
我在Bookinfo.title,Bookinfo.author和Book.isbn变量得到这个错误在我的片段内更换Bookinfo.title变化的知名度。我不知道为什么。所有文档在尝试纠正时都会给我另一个错误。至于Bookinf,它还有另一个由getter和setter组成的类。我在BookDetailsFragment类中的单词Fragment中出现错误。错误表示将@SuppressLint'NewApi'添加到BookDetailsFragment。任何帮助将不胜感激谢谢。错误:的'标题“”到“默认”或吸气剂
这里是我的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 the 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 the bundle object passed from BuyFragTab
Bundle b = getArguments();
//Getting the item's clicked position and 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")]);
return view;
}
}
这里是一个BookInfo类代码:
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() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
//returns all the previous variables to the program that made the call
@Override
public String toString() {
return title + " " + author + " " + isbn;
}
}
下面是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 the layout for this activity
setContentView(R.layout.book_details_activity_layout);
//get fragment manager for fragment related operations
FragmentManager fm = getFragmentManager();
//get fragment transaction object, which can add, move or replace a fragmnt
FragmentTransaction ft = fm.beginTransaction();
//instantiating the fragment BookDetailsFragment
BookDetailsFragment detailsFragment = new BookDetailsFragment();
//creating a bundle object to pass the data (clicked item's position)
//from this activity to fragment
Bundle b = new Bundle();
//setting the data to the bundle object from the Intent
b.putInt("position", getIntent().getIntExtra("position", 0));
System.out.println("the bundle passed" + b);
//setting the bundle object to the fragment
detailsFragment.setArguments(b);
//adding the fragment to the fragment transaction
ft.add(R.id.book_details_fragment_container, detailsFragment);
//add the fragment transaction to backstack
ft.addToBackStack(null);
//Executing the transaction
ft.commit();
}
}
下面是该onClickListener代码开始意图:
bookLV.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position,
long id){
String selectTitle, selectAuthor, selectIsbn = null;
//When item is clicked, show it's detailed view
Bookinfo bkRecs = (Bookinfo)parent.getItemAtPosition(position);
//Creating an intent object to start BookDetailsActivity
Intent bkIntent = new Intent("com.skipster.BookBarter.BOOKDETAILSACTIVITY");
//Setting data (the clicked item's position to the intent
bkIntent.putExtra("position", position);
System.out.println("Data loaded for intent");
//Start the activity
startActivity(bkIntent);
System.out.println("Intent activity started");
}
});
我想有minSkdString“7”和targetedSdkVersion =” 15“将涵盖这一点。 – Skip 2013-02-14 22:17:16
你需要支持库以及那个sdk版本。 – 2013-02-15 15:47:58