в моем приложении я перечисляю видео с большого пальца из кнопок sdcard и изображения и текстовый вид в виде списка.
без кнопок изображений в виде списка слушатель действия работает, но я добавляю кнопки изображений в виде списка, слушатель действия (тост не отображается) не работает.
мой xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="100dp"
android:background="#ffffff">
<ImageView
android:src="@drawable/icon"
android:id="@+id/Thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true" />
<LinearLayout android:orientation="vertical"
android:layout_toRightOf="@+id/Thumbnail" android:layout_width="200dp"
android:layout_height="wrap_content" android:id="@+id/textLL"
android:layout_marginLeft="10dp">
<TextView android:layout_width="wrap_content" android:text="fffff"
android:id="@+id/FilePath" android:layout_height="wrap_content"
android:textStyle="bold" android:textSize="25dp"/>
<TextView android:layout_width="wrap_content"
android:text="dskbdskkdsvsvsvvvfff"
android:layout_height="wrap_content" android:id="@+id/title2" />
<LinearLayout android:orientation="horizontal"
android:layout_gravity="center_horizontal" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton android:background="@drawable/play_btn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/imageButton2" android:layout_weight="0.5" />
<ImageButton android:background="@drawable/details_btn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/imageButton3" android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
<ImageButton android:background="@drawable/buy_btn"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:id="@+id/imageButton1" android:layout_toRightOf="@+id/textLL"/>
если я удаляю (кнопки с изображением) следующее из xml, слушатель действия (показан тост) работает.
<LinearLayout android:orientation="horizontal"
android:layout_gravity="center_horizontal" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton android:background="@drawable/play_btn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/imageButton2" android:layout_weight="0.5" />
<ImageButton android:background="@drawable/details_btn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/imageButton3" android:layout_weight="0.5" />
</LinearLayout>
and
<ImageButton android:background="@drawable/buy_btn"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:id="@+id/imageButton1" android:layout_toRightOf="@+id/textLL"/>
Если я добавлю выше (imageButtons) в слушатель действия xml не работает, я не знаю, в чем проблема с моим макетом xml. Помогите мне, пожалуйста.
мой код:
public class AndroidThumbnailList extends ListActivity{
..........
public class MyThumbnaildapter extends ArrayAdapter<String>{
public MyThumbnaildapter(Context context, int textViewResourceId,String[] objects) {
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
}
public View getView(int position, View convertView, ViewGroup parent) {
.........
}
}
protected void onListItemClick(ListView l, View v, int position, long id) {
Log.e("video", "called");
String selection = l.getItemAtPosition(position).toString();
Toast.makeText(getBaseContext(), selection, Toast.LENGTH_SHORT).show();
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
_contentUri = MEDIA_EXTERNAL_CONTENT_URI;
initVideosId();
setListAdapter(new MyThumbnaildapter(AndroidThumbnailList.this, R.layout.row, _videosId));
}
}