私が持っているレイアウト内にリストビューを作成するのに助けが必要です。私はそれを適切に作成するための問題を抱えています。
これが私がこれまでに得たものです。
item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_selector" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/gradient_bg"
android:src="@drawable/gs3ultimate" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/thelistarray"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#555555" />
<TextView
android:id="@+id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/thelistarry_details"
android:textColor="#555555"
android:textSize="10dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
これで、左側の画像、次に2つのテキストビューが表示されます。これで、2つの文字列の配列が必要になると思います。1つはタイトル用、2つ目は詳細用です。そして私は画像のための3番目のものだと思います。そうですか?
Here some java for my list view
AndroidListViewActivity.java
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class AndroidListViewActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// storing string resources into Array
String[] list_array = getResources().getStringArray(R.array.list_array);
// Binding resources Array to ListAdapter
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.item, R.id.label, list_array));
ListView lv = getListView();
// listening to single list item on click
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
}
});
}
}
詳細list_array_detailsを追加するJavaが欠落していることを知っています。そして、私はそれを追加する方法がわからないので、それは移入されます。私の意図のためにまだonitemclickを使用していません。ただし、どちらがクリックされ、どのアクティビティを起動するかを決定しますか?例。リストアイテムbをクリックして、アクティビティ「b」を高く評価したいのですが、aをクリックすると、アクティビティ「a」が起動します。
どんな助けでも大歓迎です、事前に感謝します。