kolibreath
2016-11-11 10:51安卓新手问题,小白求教大神们
写侧滑界面有两个报错
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
public class Listleft extends FragmentActivity {
public static final String[] TITLES = { "First", "Second" };
private LinearLayout mDrawer_layout;
private RelativeLayout mMenu_layout_left;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.leftfragmenty);
mDrawer_layout = (LinearLayout) findViewById(R.id.drawer_layout);
mMenu_layout_left = (RelativeLayout)findViewById(R.id.menu_left_out);
ListView menu_listview_l = (ListView) mMenu_layout_left.findViewById(R.id.menu_listView_l);
menu_listview_l.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,TITLES));
menu_listview_l.setOnItemClickListener(new DrawerItemClickListenerLeft());
}
public class DrawerItemClickListenerLeft implements OnItemClickListener{
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment fragment = null;
switch (position){
case 0:
fragment = new FirstFragment();
break;
case 1:
fragment = new SecondFragment();
break;
default:
break;
}
ft.replace(R.id.fragment_layout,fragment);
ft.commit();
mDrawer_layout.closeDrawer(mMenu_layout_left);
}
}
}
第一个是说类型不兼容,FirstFragment类不能转变成Fragement
这是我的FirstFragment类
public class FirstFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saveInstance){
return inflater.inflate(R.layout.fragment_first,null);
}
}
还有一个是 mDrawer_layout.closeDrawer(mMenu_layout_left);
无法resovle这个方法
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- 小白求教各位大神,关于java,求余数
- java
- 2个回答
- spring boot 建立项目 小白求教大神啊
- mybatis
- spring
- 框架
- 3个回答
- 小白求教大神帮忙用C语言编写一个快递管理系统,加急的。。。
- c
- 系统
- 管理
- 7个回答
- 新手求教!c语言程序执行问题,,
- c
- 程序执行
- 求教
- 新手
- 8个回答
- 小白求教二维数组遍历子数组问题
- java
- 算法
- 1个回答
换一换