在侧边菜单中实现ListView

用户4393699

这是我用来实现滑动面板的程序代码,但我想在其中制作列表视图项目。那我该怎么办呢?请帮忙。提前致谢!MainActivity代码:

// Slide the Panel
    menuRightButton = (ImageView) findViewById(R.id.menuViewButton);
    menuRightButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isExpanded) {
                isExpanded = true;
                // Expand

                FragmentManager fragmentManager = getFragmentManager();

                FragmentTransaction fragmentTransaction = fragmentManager
                        .beginTransaction();
                fragmentTransaction.replace(R.id.menuPanel,
                        new LeftMenuFragment());
                fragmentTransaction.commit();
                new ExpandAnimation(slidingPanel, panelWidth1,
                        Animation.RELATIVE_TO_SELF, 0.0f,
                        Animation.RELATIVE_TO_SELF, 0.55f, 0, 0.0f, 0, 0.0f);

            } else {
                isExpanded = false;
                // Collapse

                new CollapseAnimation(slidingPanel, panelWidth1,
                        TranslateAnimation.RELATIVE_TO_SELF, 0.55f,
                        TranslateAnimation.RELATIVE_TO_SELF, 0.0f, 0, 0.0f,
                        0, 0.0f);

            }
        }
    });

Leftmenufragement.java

//Left Menu   
public class LeftMenuFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.leftmenu, container, false);
}

}

leftmenu.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#2C323F"
 >

<ListView
    android:id="@+id/listview2"
    android:layout_width="250dp"
    android:layout_height="550dp"
    android:background="#32394A"
    android:layout_gravity="start"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp"/>

安贾利

将LeftMenuFragment更新为:

public class LeftMenuFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

     // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.leftmenu, container, false);
    ListView menuList = (ListView) view.findViewById(R.id.listview2);
  String[] items = { "Home", "Setting"};

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_list_item_1, items);

    menuList .setAdapter(adapter); 
    return view;
}

}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

实现侧边栏菜单的拖放

来自分类Dev

如何实现诸如Spotify的侧边栏菜单?

来自分类Dev

在OnsenUI中添加侧边菜单

来自分类Dev

MapView XCode 中的侧边菜单

来自分类Dev

在ListView中实现以下弹出菜单的想法

来自分类Dev

如何在Android中的ListView上实现弹出菜单

来自分类Dev

如何实现在Flutter上从右到左出现的侧边栏菜单?

来自分类Dev

侧边栏菜单实现设置根视图控制器

来自分类Dev

在Vaadin中创建侧边栏或垂直菜单

来自分类Dev

SwiftUI中macOS的侧边栏菜单

来自分类Dev

如何在侧边菜单中添加标题

来自分类Dev

在引导程序中创建侧边菜单?

来自分类Dev

在 Ionic 2 中动态更新侧边菜单

来自分类Dev

Xamarin.iOS 中的侧边栏菜单

来自分类Dev

如何在Erickras的Universal React Redux样板中的侧边栏中为生成的菜单项在route.js中实现动态路由

来自分类Dev

如何为listView中的每个项目实现上下文菜单

来自分类Dev

在listview中实现搜索

来自分类Dev

片段中实现listview

来自分类Dev

如何在Flutter中打开侧边菜单栏?

来自分类Dev

使用Tailwind CSS的侧边栏中的下拉菜单

来自分类Dev

侧边栏jquery和bootstrap菜单中的奇怪悬停行为

来自分类Dev

导航到ShinyDashboard中的特定侧边栏菜单项?

来自分类Dev

如何在 html 中添加侧边栏菜单?

来自分类Dev

侧边菜单中的字体真棒图标未对齐

来自分类Dev

在侧边菜单 Angular 4 中动画背景颜色

来自分类Dev

无法在侧边菜单中填充 tableview 单元格

来自分类Dev

CSS创建侧边菜单

来自分类Dev

基础:粘性侧边菜单

来自分类Dev

ActionBarSherlock侧边菜单导航抽屉