小编ven*_*kat的帖子

如何使用jfeinstein10/SlidingMenu在Android中实现两级滑动菜单?

我想在android中创建2级滑动菜单.当我点击第一个滑动菜单项时,我需要在左侧显示另一个滑动菜单.我使用以下代码创建了第一级滑动菜单.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/menu_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ListView    
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="@dimen/list_padding"
        android:paddingRight="@dimen/list_padding" />

</FrameLayout> 
Run Code Online (Sandbox Code Playgroud)

代码部分

SlidingMenu menu;
menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidth(10);
menu.setFadeDegree(0.0f);
menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
menu.setBehindWidth(200);
menu.setMenu(R.layout.menu_frame);
Run Code Online (Sandbox Code Playgroud)

如何进行二级滑动菜单?

android slidingmenu

12
推荐指数
1
解决办法
5537
查看次数

使用Admob插页式广告时内存泄漏

我有服务,将在特定时间点显示活动,在每13次活动后,我显示一个admob插页式广告.显示插页式广告时,我的应用程序的RAM使用量增加了20MB,之后没有收集垃圾.在接下来的第13次显示另一个插页式广告时,服务内存不会增加.

我展示广告的代码:

public void loadAndShowInterstitialAd() {
        interstitial = new InterstitialAd(getApplicationContext());
        interstitial.setAdUnitId(AD_UNIT_ID);

        final AdRequest adRequest = new AdRequest.Builder()
                .build();

        Handler handler = new Handler(new Handler.Callback() {

            @Override
            public boolean handleMessage(Message msg) {
                interstitial.loadAd(adRequest);
                return true;
            }
        });

        if (handler != null) {
            handler.sendEmptyMessageDelayed(0, 200);
        }

        interstitial.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                super.onAdLoaded();
                displayInterstitial();
            }

        });
    }

    public void displayInterstitial() {
        if (interstitial.isLoaded()) {
            interstitial.show();
        }
    }
Run Code Online (Sandbox Code Playgroud)

我在下面的堆栈溢出问题中尝试了一些解决方案,但没有任何方法可以帮助我.

Android Admob插页式内存泄漏

Android AdMob导致内存泄漏?

memory android memory-leaks eclipse-memory-analyzer android-activity

9
推荐指数
2
解决办法
2215
查看次数

android中没有找到资源异常

我想在我的Android应用程序中创建一个列表视图.但是我在运行项目时遇到资源未找到异常.

activity_main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<include
    android:id="@+id/title_bar" 
    layout="@layout/title_bar" />

<ListView 
    android:id="@+id/FeedList"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/title_bar"
    ></ListView>  

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

list_item.xml:

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

<ImageButton
   android:id="@+id/FeedType"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:background="#E0E0E0"
   android:padding="9dp"
   android:src="@drawable/ic_launcher" />

<TextView 
   android:id="@+id/FeedTitle"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Feed Title"
   android:textSize="18sp"
   android:layout_toRightOf="@+id/FeedType"
   android:paddingLeft="5dp"
   android:textColor="#000000"
   />

<TextView 
   android:id="@+id/FeedPostedBy"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_below="@+id/FeedTitle"
   android:text="by FeedOwner"
   android:layout_toRightOf="@+id/FeedType"
   android:paddingLeft="5dp"
   android:textSize="10sp"
   />

<TextView 
   android:id="@+id/FeedContent"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_below="@+id/FeedPostedBy"
   android:layout_toRightOf="@+id/FeedType"
   android:paddingLeft="5dp"
   android:paddingTop="8dp"
   android:text="The content posted as a feed by the feed owner will appear here" …
Run Code Online (Sandbox Code Playgroud)

android android-listview

3
推荐指数
1
解决办法
4780
查看次数