我想将操作项添加到 actionbar sherlock fromshelock fragment
并且还需要实现单击侦听器。我已将以下代码用于片段活动。
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
public class MyTasksFragment extends SherlockFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.mytask_fragment_layout, container, false);
return view;
}
@Override
public void onCreateOptionsMenu( Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.action_mytask, menu);
}
}
以下是action_mytask.xml
(ic_action_edit图像也在drawable文件夹中)的代码
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/action_task"
android:icon="@drawable/ic_action_edit"
android:title="@string/add_task"
android:showAsAction="ifRoom" />
</menu>
添加的图标不会出现在 ABS 中。这是图像
我想知道
How to add action items for the actionbar sherlock from sherlock fragment ?
How to implement click listners for those activities ?
请帮忙,
谢谢