0
嗨,當我運行這個我剛剛得到一個黑色的應用程序。我從一個活動到另一個活動聯繫起來,並做到這一點:如何在SDK中使用inflater顯示imageView和textView Android
CODE:
public static ImageView display;
private static LayoutInflater inflater=null;
TextView text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View vi = inflater.inflate(R.layout.activity_book, null);
display = (ImageView) vi.findViewById(R.id.imageba);
display.setImageBitmap(imageLoader.getBitmap(data.get(position)));
text=(TextView)vi.findViewById(R.id.textba);
text.setText("Titel:");
setContentView(R.layout.activity_book);
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageba"
android:layout_width="100dip"
android:layout_height="111dp"
android:layout_weight="250.17"
android:scaleType="centerCrop"
android:src="@drawable/stub" />
<TextView
android:id="@+id/textba"
android:layout_width="226dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dip"
android:layout_weight="98.53"
android:textColor="#FFFFFF"
android:textSize="15dip" />
我想只是顯示的文字和我鑽進一個TextView的位圖和成imageView。