我創建了一個圖庫,現在我想在代碼中進行更改。畫廊的元素包括兩個,我想要得到的行數。獲取圖庫元素
我想:
TextView top = (TextView)findViewById(R.id.top);
top.getLineCount();
,但應用程序崩潰的top.getLineCount();
有沒有人有一個想法? CustomAdapter
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater iteminflater = LayoutInflater.from(mContext);
View gallaryitem = iteminflater.inflate(R.layout.gallery_item, null);
ImageView imgView= (ImageView) gallaryitem .findViewById(R.id.item);
imgView.setImageResource(mImageIds[position]);
//TextView top = (TextView)convertView.findViewById(R.id.top);
//top.getLineCount();
return gallaryitem ;
}
LayoutFile
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10px" >
<ImageView
android:id="@+id/item"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:src="@drawable/icon"
android:gravity="center"
android:background="#4E4E4E"/>
<TextView
android:id="@+id/bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="moremore"
android:textSize="27sp"
android:layout_marginTop="275dip"
android:paddingTop="35dip"
android:textColor="#eeeeee"
android:background="#60000000"
android:textStyle="bold"
android:typeface="sans"/>
<TextView
android:id="@+id/top"
android:layout_width="fill_parent"
android:text="testtesttesttesttesttesttest"
android:textSize="22sp"
android:layout_marginTop="280dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:textColor="#eeeeee"
android:background="#60ff0000"
android:textStyle="bold"
android:typeface="sans"
android:layout_height="wrap_content"/>
</RelativeLayout>
你在哪裏把代碼TextView的線在你的畫廊? –
我添加了CustomAdapter和Layoutfile –
它在崩潰時得到的錯誤 –