我有這樣的佈局選項卡應用:適配器訥韋爾進入getView方法
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3dp">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom = "@android:id/tabcontent"
/>
</RelativeLayout>
</TabHost>
我想打電話給一個ListView
屏幕,所以我這樣設計:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
和gridview的樣子
<?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:orientation="vertical" android:background="#ffffff">
<ImageView
android:id="@+id/imageViewContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/textViewCategoryName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dip"
/>
</LinearLayout>
,我打電話使用適配器:
SectionsAdapter adapter = new SectionsAdapter(Sections.this ,R.layout.sectionviewgridview,
appState.MainCategories);
// updating listview
setListAdapter(adapter);
和適配器的樣子:
public class SectionsAdapter extends ArrayAdapter<HashMap<String, String>>{
ArrayList<HashMap<String, String>> mainCategories;
private final Context context;
public SectionsAdapter(Context context, int ResourceId,
ArrayList<HashMap<String, String>> items)
{
super(context, ResourceId);
this.context = context;
this.mainCategories = items ;
Log.d("The count of the hash is",""+items.size());
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Log.d("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx","I'm hereeeeeeeeeeeeeeeeeeeeeeeeee");
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.sectionviewgridview, parent, false);
ImageView ImageViewObject = (ImageView)rowView.findViewById(R.id.imageViewContent);
try {
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new java.net.URL(mainCategories.get(position).get("imageUrl")).getContent());
ImageViewObject.setImageBitmap(bitmap);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.d(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",mainCategories.get(position).get("name"));
TextView TextViewObject = (TextView) rowView.findViewById(R.id.textViewCategoryName);
TextViewObject.setText(mainCategories.get(position).get("name"));
return rowView;
}
}
它從來沒有記錄什麼的getView
方法。任何想法如何解決這個問題?