我想從shelock fragment
將操作項目添加到操作欄sherlock,並且還需要實現click監聽器。我已經使用以下代碼片段活動。如何從SherlockFragment添加操作項目
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);
}
}
而且follwing是action_mytask.xml
的添加圖標不來向ABS的代碼(ic_action_edit圖像也是在繪製文件夾)
<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>
。這裏是圖像
我想知道
How to add action items for the actionbar sherlock from sherlock fragment ?
How to implement click listners for those activities ?
請幫幫忙,
謝謝
你錯過來電super.onCreateOptionsMenu(菜單,吹氣) – Blackbelt