小编e_o*_*ori的帖子

Android:使Actionbar重叠活动布局

我有一个隐藏Actionbar的活动,当我点击一个按钮时我希望它可见,但我不希望布局活动向下滚动,栏必须重叠它.我该怎么办?

隐藏我使用的栏

actionbar.hide();
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
Run Code Online (Sandbox Code Playgroud)

并使其可见:

actionbar.show();
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
Run Code Online (Sandbox Code Playgroud)

我的布局是公正的

<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"
    >

    <MyPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    <MyPager>

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

提前致谢.

android android-activity android-actionbar

8
推荐指数
1
解决办法
2万
查看次数

无法在 Android Auto Media App 上获取语音命令

我有一个具有自动功能的 Android 应用程序已被商店拒绝,因为:

“您的应用不支持所有必需的语音命令。例如,您的应用不包含用于操作“android.media.action.MEDIA_PLAY_FROM_SEARCH”的 Intent 过滤器。”

所以我希望至少让应用程序响应“在 X 应用程序上播放音乐”,但通过查看文档我无法让它工作。我将此添加到我的主要活动中(这不是启动器活动,它通过活页夹控制服务)

<intent-filter>
  <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
  <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

触发 aMediaBrowserServiceCompat以这种方式初始化:清单:

<service
            android:name=".Services.RadioService"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
        </service>
Run Code Online (Sandbox Code Playgroud)

部分代码:

   @Override
    public void onCreate() {
        super.onCreate();
        audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
        mSession = new MediaSessionCompat(this, "RService");
        mSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS
                | MediaSessionCompat.FLAG_HANDLES_QUEUE_COMMANDS);
        mSession.setCallback(mCallback);
        mSessionConnector = new MediaSessionConnector(mSession);
        setSessionToken(mSession.getSessionToken());
        setMediaBrowser();
        initializeReceiver();
        C_F_App.createNotificationChannelPlayer(getApplicationContext());
        rNController = new RadioNotificationController(this, mSession, getApplicationContext());
    }

final MediaSessionCompat.Callback mCallback =
            new MediaSessionCompat.Callback() {
                @Override
                public void onPlayFromMediaId(String mediaId, …
Run Code Online (Sandbox Code Playgroud)

android android-auto

8
推荐指数
1
解决办法
1382
查看次数

Android - Viewpager和片段,方法不起作用

我有ViewPager两个Fragments我实例化onCreateFragmentActivity.

private List<Fragment> fragments = new Vector<Fragment>();

fragments.add(Fragment.instantiate(this,Frag_1.class.getName()));
fragments.add(Fragment.instantiate(this,Frag_2.class.getName()));
    this.vPagerAdapter = new Adapt(super.getSupportFragmentManager(),fragments);
    vPager = (ViewPager) super.findViewById(R.id.pager);
    vPager.setAdapter(vPagerAdapter);
Run Code Online (Sandbox Code Playgroud)

我的第二个Fragment有一个方法,我打电话来更新我的ListView- refreshList():

public class Frag_2 extends Fragment {

    private ListView list;
    private ArrayList<data> data;
    private boolean firstCreation=true;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setRetainInstance(false);
    }   

    public void onAttach(Activity activity) {
        // TODO Auto-generated method stub
        super.onAttach(activity);
    }

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View view = …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-viewpager android-fragmentactivity

6
推荐指数
1
解决办法
2496
查看次数

ScrollView使自定义布局不可见

我做了一个Viewgroup我需要在我的应用程序中使用的自定义,但我需要把它放在一个ScrollView.当布局只用我的自定义ViewGroup一切正常,但当我把它放在一个ScrollView我看不到任何东西.我的布局:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <com.example.test.CustomLayout
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </com.example.test.CustomLayout>

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

我的观点组:

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){

        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            /* do something and call for each child             
                    View v = getChildAt(i);
                    v.measure(wspec, hspec);
                    */

        setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec), getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec));

    }

    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        // TODO Auto-generated method stub
        //do something and call layout on every child 
    }
Run Code Online (Sandbox Code Playgroud)

更新:我的CustomLayout类 …

layout android viewgroup

6
推荐指数
1
解决办法
3259
查看次数

在渲染之前测量视图并获得剩余空间(Android)

我试图解决这个问题很多年但我找不到解决方案:我需要知道带有一些HTML文本的webview在一个LinearLayout中需要多少高度,如果占用的空间不会超过屏幕size我必须添加另一个带有其他HTML文本的webview.我无法弄清楚如何做到这一点,我试着调用measure()但它会给我0尝试使用的任何measurepec.有人知道怎么做吗?提前致谢.

android webview measure android-linearlayout

5
推荐指数
0
解决办法
276
查看次数

Android IAB错误RPC:S-7 AEC-0

我使用应用内结算制作了应用,对其进行了测试并发布了它,没有任何问题.应用内购买有效.现在我正在使用新的应用内购买进行更新,并且无法通过我的新更新购买任何内容,Play商店购买片段总是给我这样的消息:

Error while retrieving informations from server [RPC:S-7:AEC-0]
Run Code Online (Sandbox Code Playgroud)

Logcat给了我这个错误:

02-12 12:15:27.524: E/Volley(5650): [629] BasicNetwork.performRequest: Unexpected response code 500 for https://android.clients.google.com/fdfe/commitPurchase
02-12 12:15:27.539: D/Finsky(5650): [1] PurchaseFragment.handleError: Error: PurchaseError{type=2 subtype=0}
Run Code Online (Sandbox Code Playgroud)

Play商店应用与我正在开发的版本具有相同的版本代码,我的测试帐户是手机上的第一个帐户.应用内商品已经发布并处于活动状态.我尝试删除我的测试帐户并对其进行读取,从Google Play服务和Play商店中清除数据和缓存,即使其他用户也提供了同样的错误.请帮帮我,我真的不知道该怎么办.

error-handling android in-app-purchase

5
推荐指数
1
解决办法
416
查看次数

自动:在进行后台通话时显示进度

我们有一个音频应用程序,我们想为其添加 Android Auto 功能。该应用程序基本上有一个广播流列表,用户可以选择播放哪一个。

为了获取流,我需要调用 Web 服务并获取流,而在发生这种情况时,我希望至少在汉堡菜单上显示不确定的进度,就像 Spotify 在加载内容时所做的那样。

此时如果我已经下载了流,在我的MediaBrowserServiceCompat自动调用时,onLoadChildren我的Result<List<MediaBrowserCompat.MediaItem>> result对象填充了 MediaItems,如果我没有它们,我只发送一个空的 MediaItems 数组并调用 API,一旦它完成我调用notifyChildrenChanged在服务和流列表出现,但在那之前我有一个“没有项目”的消息。

我在 Android 开发人员网站上找不到设置子菜单以显示加载的方法,我找不到执行此操作的示例应用程序。没有人知道是否有办法,说不定什么时候onGetRoot被调用,让自动知道它调用之前等待onGetRootonLoadChildren?我也尝试调用 API 然后调用自己,onGetRoot但它没有用。

提前致谢。

android android-auto

5
推荐指数
1
解决办法
398
查看次数

Android IAB错误 - 需要身份验证

我在我的应用程序中测试In App Billing()v3时遇到问题,我不能用测试帐户购买任何东西.它总是显示一个Play商店对话框

"Error Authentication is required. You must log in with your Google Account"
Run Code Online (Sandbox Code Playgroud)

我只能毫无问题地购买保留项"android.test.purchased"并使用它.

IAB开始:

private static final int REQ_CODE_BUY = 51667;
    private static final String buyFile = "bought";

    private Activity activity;
    private ProgressDialog pD;
    private IInAppBillingService mService;
    private ServiceConnection mServiceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            mService = null;
        }

        @Override
        public void onServiceConnected(ComponentName name, 
                IBinder service) {
            mService = IInAppBillingService.Stub.asInterface(service);
        }
    };

    public IABHelper(Activity activity, ProgressDialog pD){
        this.activity = activity;
        this.pD = …
Run Code Online (Sandbox Code Playgroud)

android in-app-purchase

4
推荐指数
1
解决办法
3458
查看次数

Android 4.0中的9个补丁按钮太高了

我的应用程序有9个补丁按钮,在Android 2.3中它们显示正常,但是当我在Android 4.0的设备中尝试按钮太高时,我需要它们在Android 2.3中.

他们wrap_content在布局中.

图像中的Android 2.3:http://picturepush.com/public/12502980
在图像的Android 4.0:http://picturepush.com/public/12502985
我9patch按钮:http://picturepush.com/public/12502990

有什么问题,我该如何解决?

android button nine-patch

0
推荐指数
1
解决办法
401
查看次数