list android 按钮,android-ListFragment每行带有按钮

我有一个应用程序,几乎是这样的:

我尝试遵循此http://developer.android.com/guide/components/fragments.html(为活动创建事件回调),但似乎不起作用.我的意思是,我想选择每一行以查看详细信息,而且我希望能够单击我想要的任何行的按钮a,b或c.我不确定如何将按钮与其行关联.

这是我的rowLayout.xml:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal" >

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:stretchColumns="0,1">

android:layout_width="match_parent"

android:layout_height="wrap_content" >

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="left">

android:id="@+id/imageViewTypeClient"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

tools:ignore="ContentDescription" />

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

android:id="@+id/textView2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="5dp"/>

android:gravity="right"

android:layout_width="wrap_content"

android:layout_height="wrap_content">

android:id="@+id/imageButtonSync"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:src="@android:drawable/stat_notify_sync"/>

android:id="@+id/imageButtonDelete"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:src="@android:drawable/ic_menu_delete"

tools:ignore="ContentDescription" />

android:id="@+id/imageButtonEdit"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:src="@android:drawable/ic_menu_edit" />

我采用这种方式来获得所需的订单.

这是我的ListFragment:

public class AplicacionActivity extends FragmentActivity implements OnEmployeeSelectedListener {

public void onEmployeeSelected(int id) {

Log.e("activity aplicacion", "entre");

Bundle arguments = new Bundle();

arguments.putLong("id", id);

DataClientActivity fragment = new DataClientActivity();

fragment.setArguments(arguments);

getSupportFragmentManager().beginTransaction()

.replace(android.R.id.tabcontent,fragment, AplicacionActivity.tagFragmentDataClient)

.commit();

}

...

}

这是我的ListFragment:

public class ClientsActivity extends ListFragment {

OnEmployeeSelectedListener mEmployeeListener;

public interface OnEmployeeSelectedListener {

public void onEmployeeSelected(int id);

}

@Override

public void onAttach(Activity activity) {

super.onAttach(activity);

try {

mEmployeeListener = (OnEmployeeSelectedListener) activity;

} catch (ClassCastException e) {

throw new ClassCastException(activity.toString() + " you must implement OnEmployeeSelectedListener");

}

}

@Override

public void onListItemClick(ListView l, View v, int position, long id) {

int idEmployee = position;

// Send the event and Uri to the host activity

mEmployeeListener.onEmployeeSelected(idEmployee);

}

我只是尝试运行此命令,但是当我按列表的任何行时,不会调用onListItemClick.

尽管如此,我不知道是否必须对按钮进行类似的操作.

如果有人可以为我提供教程或为我提供正确的指导,我将非常感激.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值