小编Aas*_*ish的帖子

将HTML文件加载到WebView中

我有一个本地html页面以及它所指向的其他几个资源(css文件和Javascript库),我想加载到WebView中.怎么能实现这一目标?

也许不是最好的方式,但我还在试验.

android local android-webview

181
推荐指数
3
解决办法
17万
查看次数

设置视图文本在android中的微调器中心对齐

视图文本中最中心的最微调 - 当 - 选择 - 来自该下拉列表

我想将微调器的视图文本与中心对齐.我谷歌但没有找到任何东西,有人知道吗?任何帮助或建议表示赞赏

android text-alignment android-spinner

36
推荐指数
5
解决办法
8万
查看次数

方向更改时如何防止youtube片段视图重新加载

我想防止在应用中的方向发生变化时重新加载youtube片段视图。我在用YouTubeAndroidPlayerApi.jar

我已经添加了android:configChanges =“ orientation | screenSize”,但是它不能保护重新加载。

AndroidManifest.xml

<activity android:name=".MainActivity"
        android:theme="@style/AppTheme"
        android:configChanges="orientation|screenSize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

activity_main.xml

<fragment
    android:id="@+id/youtube_player_fragment"
    android:name="com.google.android.youtube.player.YouTubePlayerFragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String youTubeKey = getString(R.string.YouTubeKey);

        YouTubePlayerFragment youTubePlayerFragment = (YouTubePlayerFragment) getFragmentManager().findFragmentById(R.id.youtube_player_fragment);
        youTubePlayerFragment.initialize(youTubeKey, this);
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
    youTubePlayer = player;

    //Enables automatic control of orientation
    youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
    //Show full screen in landscape mode …
Run Code Online (Sandbox Code Playgroud)

android youtube-api android-fragments android-orientation

7
推荐指数
1
解决办法
150
查看次数

长按从 WebView 保存图像

需要帮忙

我正在尝试通过长按照片从 webview 下载图片,当我使用 Toast 消息测试长按操作时,它起作用了

但它没有下载。

 private View.OnLongClickListener listener=new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            mWebView.setDownloadListener(new DownloadListener() {

                @TargetApi(Build.VERSION_CODES.HONEYCOMB)
                public void onDownloadStart(String url, String userAgent,
                                            String contentDisposition, String mimetype,
                                            long contentLength) {
                    DownloadManager.Request request = new DownloadManager.Request(
                            Uri.parse(url));

                    request.allowScanningByMediaScanner();
                    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed!
                    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "Name of your downloadble file goes here, example: Keerthi");
                    DownloadManager dm = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
                    dm.enqueue(request);
                    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); //This is important!
                    intent.addCategory(Intent.CATEGORY_OPENABLE); //CATEGORY.OPENABLE
                    intent.setType("*/*");//any application,any extension
                    Toast.makeText(getContext(), "Downloading …
Run Code Online (Sandbox Code Playgroud)

android image download webview long-press

6
推荐指数
2
解决办法
7260
查看次数

错误:当我用gradle(dependency)中的实现替换compile时

我将Android Studio从3.0.1更新为3.1.0

但是在更新后,当我构建项目时,它显示2警告

1.将编译替换为实现(编译支持将于2018年底终止)

2.用testImplementaion替换testCompile(并且testCompile支持将在2018年底终止)

因此,最后进行这些更改,但是之后,它显示了一些错误

错误

build.gradle(模块:应用)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "biz.coolpage.aashish.app"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 4
        versionName "1.2.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:27.1.0'
    implementation project(':library')
}
Run Code Online (Sandbox Code Playgroud)

build.gradle(Project:Abc)

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
    }
}

allprojects {
    repositories {
        jcenter() …
Run Code Online (Sandbox Code Playgroud)

android updates android-studio javacompiler

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

如何在Android上的"打开方式"列表中显示我的应用程序

我创建了一个简单的应用程序webview,可以处理/打开任何URL.但问题是,当我点击任何超链接时,我的应用程序将不会列表显示.

图像打开列表

如上图所示,我单击一个超链接,它弹出一个打开的列表,但我的应用程序没有显示在这里.所以,我想显示我的应用程序也显示在此打开列表中.

清单代码:

<application
    android:allowBackup="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity
        android:name="biz.coolpage.aashish.app.MainActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.Translucent.Light"
        android:hardwareAccelerated="true"
        android:launchMode="singleInstance"
        android:alwaysRetainTaskState="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:mimeType="text/link"
                android:scheme="http" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="text/plain"/>
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

android open-with android-manifest

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

如何将 wamp 2.5 更新到 3.0.6

我想将我的 wamp 服务器从 2.5 更新到 3.0.6,因为我的项目需要 PHP 5.6 或更高版本。但是wamp 2.5上有很多数据库和项目,所以我想更新它而不是卸载旧版本并安装wamp 3.0

实现它的简单和最好的方法是什么?

wampserver updates server

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