小编Den*_*sVA的帖子

没有为app找到资源ID:来自CollapsingToolbarLayout的layout_scrollflags

这个问题的标题基本上都说明了一切.我收到错误:找不到app:layout_scrollflags来自CollapsingToolbarLayout的资源标识符.我使用eclipse并导入了设计库jar文件.我能够在我的类中使用设计支持布局,这是正确的

这是我使用的一段代码:

<LinearLayout 
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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/activityBg"
tools:context=".MainActivity"
>

<android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent">

    <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <include
            layout="@layout/toolbar"/>

    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)

示例:http://android-developers.blogspot.in/2015/05/android-design-support-library.html

android androiddesignsupport android-collapsingtoolbarlayout

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

在webview中向上滚动会导致SwipeRefreshLayout刷新

我在FrameLayout中有一个WebView,因为我正在创建一个浏览器来添加标签.FrameLayout位于SwipeRefreshLayout内.

问题:每当我在WebView中快速滚动内容时,工具栏后面会出现刷新图标.它应该只在WebView内容位于顶部时才会发生.它与FrameLayout有关,当我删除它时,问题就消失了.

布局如下所示:

<SwipeRefreshLayout
            android:id="@+id/swipeRefresh"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

        <FrameLayout
        android:id="@+id/webViewFrame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"    
        >
        <WebView
            android:id="@+id/webView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
        </FrameLayout>

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

android android-webview swiperefreshlayout android-framelayout

11
推荐指数
1
解决办法
2431
查看次数

NestedScrollView中的WebView问题

我在NestedScrollView中放置了一个WebView.在用户在WebView中向下/向上滚动时隐藏/显示工具栏.

不幸的是,有一些问题:

  1. 单击导航到较小网页(高度)的网页中的URL时,webview底部会显示一个空白区域.当我删除这个
  2. HTML中的javascript viewpager有sidecrolling问题,但我的WebView中启用了javascript.

当我删除NestedScrollView时,两个问题都消失了,但工具栏隐藏和显示不再起作用

这是我的布局:

<android.support.v4.widget.DrawerLayout 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/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    tools:context=".MainActivity">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/toolbar"
                style="@style/toolbarStyle"
                android:layout_width="match_parent"
                android:layout_height="57dp"
                app:layout_scrollFlags="scroll|enterAlways">

                <RelativeLayout
                    android:id="@+id/focusHolder"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:paddingBottom="10dp"
                    android:paddingTop="10dp">

                    <Button
                        android:id="@+id/tmpBtn"
                        android:layout_width="48dp"
                        android:layout_height="match_parent"
                        android:layout_alignParentRight="true"
                        android:background="@null" />

                    <EditText
                        android:id="@+id/addressBar"
                        style="@style/addressBarStyle"
                        android:layout_width="match_parent"
                        android:layout_height="30dp"
                        android:layout_centerVertical="true"
                        android:layout_toLeftOf="@id/tmpBtn"
                        android:imeOptions="actionGo"
                        android:singleLine="true" />
                </RelativeLayout>
            </android.support.v7.widget.Toolbar>
        </android.support.design.widget.AppBarLayout>

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/darkGreen"
            android:fillViewport="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <RelativeLayout
                android:id="@+id/webViewWrapper"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/yellow">

                <WebView
                    android:id="@+id/webView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />

                <ProgressBar
                    android:id="@+id/progressBar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true" /> …
Run Code Online (Sandbox Code Playgroud)

android toolbar scrollview webview material-design

8
推荐指数
0
解决办法
1615
查看次数

进程被操作系统终止后重新启动应用程序

当应用程序处于后台并且需要更多内存时,Android 会终止该应用程序的进程。

我读过几篇有关此的文章。有些人建议发生这种情况时重新启动应用程序。但没有一篇文章向我提供有关如何做类似事情的信息。

在应用程序的进程被销毁并且应用程序返回到前台后,有没有办法返回到根活动?做这样的事情最好的方法是什么?

memory android

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

对讲读取每个活动的应用程序名称

当我在我的应用程序中导航时。Talkback 会告诉我每个新活动中的应用程序名称。

我想知道这是否是预期的行为。如果没有,我该怎么办

我在https://developer.android.com/training/accessibility上找不到任何关于此的信息

android accessibility talkback

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

来自 ConnectivityManager 的具有相同 networkId 的多个随机 NetworkCallbacks (onAvailable)

我不明白为什么在随机时刻多次调用 onAvailable ,文档说明如果网络发生变化可以调用更多,但是 onAvailable 中网络对象参数的属性始终相同。我什至比较了哈希码,它们是相同的......

问题出现在我的 LG 棒棒糖设备上

Android 文档:(https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback

onAvailable 在 API 级别 21 中添加当框架连接并声明新网络可供使用时调用。如果满足请求的网络发生变化,则此回调可能会被多次调用

编辑:我已经从回调中实现了其他方法来检查是否有任何其他方法被触发(onLosing、onUnavailable、onCapabilitiesChanged、onLinkPropertiesChanged),但这些方法都没有被调用

我有自己的 NetworkManager,其中包含以下代码:

public void initialize(Context context) {
    connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    setState();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        final NetworkRequest networkRequest = new NetworkRequest.Builder()
                .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
                .addTransportType(NetworkCapabilities.TRANSPORT_WIFI).build();

        connectivityManager.registerNetworkCallback(networkRequest, new ConnectivityManager.NetworkCallback() {
            @Override
            public void onAvailable(final Network network) {
                super.onAvailable(network);
                NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
                Log.d(TAG,"Network is Available. Network Info: " + networkInfo);
                notifyObservers();
            }

            @Override
            public void onLost(final Network network) {
                super.onLost(network);
                notifyObservers(); …
Run Code Online (Sandbox Code Playgroud)

java android android-connectivitymanager

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

片段继承Android

是否有可能/建议让不同的片段在Android中相互继承?

初始化已经在超类中初始化并添加内容的东西的最佳方法是什么?( - >例如像在构造函数中使用super()然后初始化其他对象的普通子类一样)

我在互联网上查看,但我没有找到关于此的更多信息.我知道可以返回super.onCreateView()但你不能在那之后初始化其他对象/视图....

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

    super.onCreateView()???


    //initialize other objects here

    //you have to return a view ...
}
Run Code Online (Sandbox Code Playgroud)

inheritance android fragment

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

Android内存测试

这可能是一个愚蠢的问题,但我似乎无法在互联网上找到很多具体的信息.

假设我有2个活动:MainActivity和Secondactivity.mainactivity有一个按钮可以进入第二个活动.第二个活动有一个返回主活动的按钮(下面非常简单的代码).

我试图了解android内存管理,这就是为什么我正在做这个测试.

我的问题:

当我经常在活动之间来回走动时,在查看Android工作室中的内存图时,我可以看到一个蓝色图表,它永远不会回到它在应用程序启动时分配的内存.我有内存泄漏吗?(可能不是因为这是基本代码).但是为什么它一开始就不会回到它原来分配的内存?

主要活动只有这种方法:

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

    Button btnTest = (Button) findViewById(R.id.btnTest);
    btnTest.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v)
        {
            Log.i(null, "test");
            finish();
            startActivity(new Intent(MainActivity.this, SecondActivity.class));
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

虽然SecondAcitivity只是回到第一个并创建了一些按钮

public class SecondActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);

    Button btnTest = (Button) findViewById(R.id.btnTest);
    btnTest.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v)
        {
            Log.i(null, "test");
            finish();
            startActivity(new Intent(SecondActivity.this, MainActivity.class));
        }
    });

}
Run Code Online (Sandbox Code Playgroud)

}

在此输入图像描述

memory heap stack android

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

系统杀死应用程序后碎片会发生什么?

“如果一个活动被暂停或停止,系统可以通过要求它完成或简单地终止其进程来从内存中删除该活动。”。当用户返回到 Activity 时,它会用一个包恢复它的状态。

我的问题是:

在 oncreate 中执行此操作是否重要:

if(savedinstance != null)
{
    fragement = fm.findFragmentByTag("tag");
}
else
{
    fragment = new Fragment();
    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.id.webViewFrame,fragment,"tag");
    ft.commit()
}
Run Code Online (Sandbox Code Playgroud)

而不仅仅是这个:

    fragment = new Fragment();
    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.id.webViewFrame,fragment,"tag");
    ft.commit()
Run Code Online (Sandbox Code Playgroud)

android state fragment

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

android.app.RemoteServiceException:在华为Y6上发布了错误的通知

我在运行Android 5.1的特定华为设备(HUAWEI TIT-L01)上崩溃

我找不到使用Google的大量信息

堆栈跟踪:

android.app.RemoteServiceException: Bad notification posted from package 
com.myapp.test: Couldn't expand RemoteViews for: 
StatusBarNotification(pkg=com.myapp.test user=UserHandle{0} 
id=1 tag=null score=0 key=0|com.myapp.test|1|null|10693: 
Notification(pri=0 contentView=com.myapp.test/0x109007e 
vibrate=null sound=null defaults=0x0 flags=0x0 color=0x00000000 
category=transport actions=3 vis=PRIVATE))
Run Code Online (Sandbox Code Playgroud)

代码(我没有写这个,所以不要判断我):

private static void buildNotification(Notification.Action action) 
{
    final Notification.MediaStyle style = new Notification.MediaStyle();

    final Intent intent = new Intent(MyApplication.getAppContext(), MediaPlayerService.class);
    intent.setAction(ACTION_STOP);
    final PendingIntent pendingIntent = PendingIntent.getService(MyApplication.getAppContext(), 1, intent, 0);

    Bitmap coverImage = null;
    String bookTitle = "";
    String author = "";
    if (PlaybackUtils.INSTANCE.getCurrentBookPerformant() != null) {
        coverImage = …
Run Code Online (Sandbox Code Playgroud)

java notifications android huawei

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