Добрый день.В моем приложении у меня есть три вкладки (одна активность расширяет TabActivity, а другая активность обеспечивает доступ к контенту).В первой вкладке у меня есть ImageView, несколько TextView, и это работает.Но когда я добавляю ListView и в активности, которая содержит ListView, я добавляю несколько строк, которые не были показаны на вкладке май.
Может кто-нибудь сказать мне, где я был не прав?Вот мой код:
В StartActivity:
intent = new Intent().setClass(this, GoodsAndShopsActivity.class);
spec = tabHost.newTabSpec("shops").setIndicator("Shops",
res.getDrawable(R.drawable.ic_tab_shops))
.setContent(intent);
tabHost.addTab(spec);
В GoodsAndShopsActivity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.descriptions);
m_shopsLayout = (ListView) findViewById(R.id.shops);
m_shopList = new ArrayList<Shop>();
m_shopAdapter = new ShopAdapter(m_shopList, this);
m_shopsLayout.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
m_shopsLayout.setAdapter(m_shopAdapter);
for (int i = 0; i<3; i++) {
m_shopList.add(new Shop("new description"));
m_shopAdapter.notifyDataSetChanged();
}
}
В классе, который расширяет BaseAdapter:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = m_inflater.inflate(R.layout.shop, null);
holder = new ViewHolder();
holder.descriptions = (TextView) convertView.findViewById(R.id.shop);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
String textOnView = m_shops.get(position).getDescription();
holder.descriptions.setText(textOnView);
return convertView;
}
static class ViewHolder{
TextView descriptions;
}
Имой xml, где определяют ListView (извините, что так много):
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/full_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10px"
android:src="@drawable/icon">
</ImageView>
<LinearLayout
android:id="@+id/short_info"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/icon"
android:layout_alignParentRight="true">
<TextView
android:id="@+id/name_for_good"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Наименование товара">
</TextView>
<TextView
android:id="@+id/best_price"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:ellipsize="marquee"
android:text="Лучшая цена: ">
</TextView>
<TextView
android:id="@+id/worst_price"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:text="Худшая цена: ">
</TextView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/description_and_shop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/full_info">
<TextView
android:id="@+id/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Большое подробное описание товара с всякими деталями, нюансами и т.п.">
</TextView>
<ScrollView
android:id="@+id/ScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/shops"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</ScrollView>
</LinearLayout>
ОБНОВЛЕНИЕ: После перерыва на кофе я обнаружил ошибку: в моем XML я добавляю в последнийLinearLayout "direction = vertical" и мои строки появились. решаемые