小编Suf*_*ian的帖子

如何从我的应用程序中在Android的Web浏览器中打开URL?

如何从内置Web浏览器中的代码而不是在我的应用程序中打开URL?

我试过这个:

try {
    Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(download_link));
    startActivity(myIntent);
} catch (ActivityNotFoundException e) {
    Toast.makeText(this, "No application can handle this request."
        + " Please install a webbrowser",  Toast.LENGTH_LONG).show();
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

但我有一个例外:

No activity found to handle Intent{action=android.intent.action.VIEW data =www.google.com
Run Code Online (Sandbox Code Playgroud)

url android android-intent android-browser

1282
推荐指数
16
解决办法
81万
查看次数

如何监听WebView完成加载URL?

我有一个WebView从Internet上加载页面.我想显示一个ProgressBar直到加载完成.

我如何监听完成页面加载WebView

android android-webview

422
推荐指数
10
解决办法
31万
查看次数

如何在Fragments中实现onBackPressed()?

有没有一种方法可以onBackPressed()在Android Fragment中实现类似于我们在Android Activity中实现的方式?

正如Fragment生命周期所没有的那样onBackPressed().有没有其他替代方法来覆盖onBackPressed()Android 3.0碎片?

android android-fragments onbackpressed

422
推荐指数
28
解决办法
41万
查看次数

如何检测我是处于发布模式还是调试模式?

如何在我的代码中检测到我处于发布模式或调试模式?

android android-build-type

336
推荐指数
8
解决办法
11万
查看次数

我该如何验证电子邮件地址?

在Android中验证电子邮件地址(例如来自用户输入字段)的好方法是什么?org.apache.commons.validator.routines.EmailValidator似乎不可用.有没有其他图书馆这样做已经包含在Android中,或者我是否必须使用RegExp?

android email-validation

312
推荐指数
16
解决办法
21万
查看次数

取消handler.postdelayed进程

我正在使用handler.postDelayed()我的应用程序的下一个阶段之前创建一个等待期.在等待期间,我显示一个带有进度条和取消按钮的对话框.

我的问题是我找不到在时间流逝之前取消postDelayed任务的方法.

android postdelayed android-handler

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

方法setDrawerListener已弃用

当我在我的应用程序上做某事时,我看到我的应用程序上的导航抽屉减小了它的大小.但是我没有做任何事情.

导航抽屉

然后,在检查代码后,我看到不推荐使用setDrawerListener.有人有解决方案吗?任何帮助都可以.先感谢您!

drawerLayout.setDrawerListener(actionBarDrawerToggle);
Run Code Online (Sandbox Code Playgroud)

android drawerlayout deprecation-warning

219
推荐指数
4
解决办法
8万
查看次数

SwipeRefreshLayout setRefreshing()最初没有显示指标

我有一个非常简单的布局,但是当我打电话setRefreshing(true)onActivityCreated()我的片段,将其最初不显示.

它只显示我何时刷新.任何想法为什么它最初没有出现?

片段xml:

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_container"
    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">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

        </RelativeLayout>


    </ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

片段代码:

public static class LinkDetailsFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {

    @InjectView(R.id.swipe_container)
    SwipeRefreshLayout mSwipeContainer;

    public static LinkDetailsFragment newInstance(String subreddit, String linkId) {
        Bundle args = new Bundle();
        args.putString(EXTRA_SUBREDDIT, subreddit);
        args.putString(EXTRA_LINK_ID, linkId);

        LinkDetailsFragment fragment = new LinkDetailsFragment();
        fragment.setArguments(args);

        return fragment;
    }

    public LinkDetailsFragment() {
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        mSwipeContainer.setOnRefreshListener(this);
        mSwipeContainer.setColorScheme(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
        mSwipeContainer.setRefreshing(true);
    } …
Run Code Online (Sandbox Code Playgroud)

android swiperefreshlayout

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

如何以编程方式创建ColorStateList?

我正在尝试ColorStateList使用这个以编程方式创建:

ColorStateList stateList = new ColorStateList(states, colors); 
Run Code Online (Sandbox Code Playgroud)

但我不确定这两个参数是什么.

根据文件:

public ColorStateList (int[][] states, int[] colors) 
Run Code Online (Sandbox Code Playgroud)

在API级别1中添加

创建一个ColorStateList,它返回从状态到颜色的指定映射.

有人可以解释一下如何创建这个吗?

状态二维数组的含义是什么?

android android-color

139
推荐指数
6
解决办法
8万
查看次数

如何在单击操作后关闭通知

从API级别16(Jelly Bean)开始,可以使用通知添加操作

builder.addAction(iconId, title, intent);
Run Code Online (Sandbox Code Playgroud)

但是当我向通知添加操作并按下操作时,通知不会被解除.单击通知本身时,可以将其解除

notification.flags = Notification.FLAG_AUTO_CANCEL;
Run Code Online (Sandbox Code Playgroud)

要么

builder.setAutoCancel(true);
Run Code Online (Sandbox Code Playgroud)

但显然,这与通知相关的操作无关.

任何提示?或者这不是API的一部分?我没找到任何东西.

android action android-notifications

132
推荐指数
8
解决办法
10万
查看次数