小编Viv*_*ngh的帖子

在API级别19以下的Android中选择文件或图像时,如何限制Google驱动器选项不显示?

我是Android的新手,我要求在API级别19以下的设备上选择文件.

我试过了

private void chooseFile() {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
             intent.setType("application/pdf|file");
        } else {
             intent.setType("image/*|application/pdf");
        }
        startActivityForResult(intent, PICKFILE_REQUEST_CODE);
}
Run Code Online (Sandbox Code Playgroud)

现在我不希望Google驱动器作为选项出现,我想要文件管理器作为选项.我想用意图来做这件事.

任何人都可以建议我如何实现这一目标?

android android-intent

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

检测每个触摸事件而不获取应用程序上下文?

我们可以通过在上下文中使用getWindow()获取每个Activity的Touch事件:

//set Window.Callback for getting touch event 
        final Window window = context.getWindow();
        final Window.Callback localCallback = window.getCallback();
        window.setCallback(new MyWindowCallback(localCallback));
Run Code Online (Sandbox Code Playgroud)

如何在不使用上下文的情况下实现它?

有没有办法删除这个回调(因为窗口类没有任何删除回调方法?

android android-activity

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

在android中使用Intent挑选PDF文件

嘿,我是 android 新手,我需要pdf使用 Intent. 我正在使用此代码来设置 MIME 类型。

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("pdf/*")
Run Code Online (Sandbox Code Playgroud)

但它没有按我想要的方式工作,请向我提供任何建议,或者我可以对现有代码进行一些更改。

android android-intent

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

如何在回收站视图行中添加动态视图

我有一个回收站视图,在每行内部我有一个线性布局,我必须根据每行的数据动态插入一些视图.

我试过了

for(int i=0;i<4;i++){
    View view = LayoutInflater.from(context).inflate(R.layout.sales_total_item_with_img,null);
    holder.dynamicLinearLayout.addView(view);
}
Run Code Online (Sandbox Code Playgroud)

上面的代码写在onBindHolder方法中并且工作但每次滚动时它都在膨胀,这个东西只是添加了越来越多的视图

任何人都可以告诉我,如果我做错了什么,并建议我更好的方法?

android adapter android-recyclerview

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

如何在浮动操作按钮上方放置透明布局

我正在开发一个应用程序,我想在整个屏幕上放置一个透明视图,我在这方面取得了一定的成功,但我的屏幕包含浮动操作按钮,
我也无法将透明布局放在浮动操作按钮上方

这是我的 xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.groomefy.consumer.Trending.DetailedActivity">

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="370dp"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <RelativeLayout
            android:id="@+id/layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="-10dp"
            app:layout_collapseMode="parallax">

            <ImageView
                android:id="@+id/main_image"
                android:layout_width="match_parent"
                android:layout_height="430dp"
                android:scaleType="fitEnd"
                android:src="@drawable/image_placeholder_square" />

            <!--
                            <ImageView
                                android:id="@+id/curve_image"
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:layout_alignParentBottom="true"
                                android:layout_marginBottom="-20dp"
                                android:scaleType="fitEnd"
                                android:src="@drawable/postdetail_curve"
                                app:layout_anchor="@id/main_image"
                                app:layout_collapseMode="none" />
            -->
        </RelativeLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/white"
            app:contentInsetEnd="0dp"
            app:contentInsetLeft="0dp"
            app:contentInsetRight="0dp"
            app:contentInsetStart="0dp"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/AppTheme.PopupOverlay">

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="10dp">

                    <ImageButton
                        android:id="@+id/btn_cancel"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:background="@android:color/transparent"
                        android:padding="10dp"
                        android:src="@drawable/backicon" …
Run Code Online (Sandbox Code Playgroud)

android transparent floating-action-button android-coordinatorlayout

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