我有这个类来定义我的滑动菜单项,并且我想在单击其中一些时启动不同的意图(不是片段,而是活动)。
public class RggarbSlidingMenu extends SherlockListFragment{
String[] list_contents = {
"My Profile",
"My Items",
"Messages",
"Notifications",
"Items Feed",
"People Feed",
"Places Feed",
"Privacy Policy",
"Terms of Service",
"Settings",
"Log Out"
};
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
return inflater.inflate(R.layout.list, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, list_contents));
}
@Override
public void onListItemClick(ListView l, View v, int position, long id){
if (position == 0) {
Intent signup = new Intent(RggarbSlidingMenu.this, Signup.class);
startActivity(signup);
} else if (position == 1) {
} else if (position == 2) {
} else if (position == 3) {
} else if (position == 4) {
}
}
}
但在以下几行
if (position == 0) {
Intent signup = new Intent(this, MyProfile.class);
startActivity(signup);
我收到此错误:
The constructor Intent(RggarbSlidingMenu, Class<Signup>) is undefined
我怎样才能从这里开始一个意图?
另外,我如何为项目使用选择器,这不是他们的位置,因为这让我很困惑,我想用他们的名字来选择他们?