小编Far*_*sbi的帖子

自 Android Studio 4.2 起,没有可见的可调试进程

将我的 android studio 更新到版本 4.2 后,我在 Logcat 中没有可供选择的可调试进程。构建变体肯定是调试的,我已经检查了解决我的问题的其他 StackOverflow 帖子,但没有找到任何内容。另外,我尝试了旧版本,结果发现4.1.3没有这个问题,进程是可见的,但我在4.2和4.2.1以及BumbleBee上有这个问题,看来新版本有问题。我想知道其他人是否也遇到同样的问题,任何帮助将不胜感激。

注意:即使调试器也无法附加到进程

在此输入图像描述

android logcat android-studio

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

防止Bottom Sheet祖先视图中的滚动

我有一个CoordinatorLayout包含两个NestedScrollViews,一个有ScrollingViewBehavior,另一个有BottomSheetBehavior和扮演BottomSheet角色,问题是当我拖动时BottomSheet,第一个NestedScrollView滚动:

在此输入图像描述

我的期望:
当我滚动时BottomSheet,另一个NestedScrollView不应该滚动

我试了一下:
我创建了一个自定义的行为和覆盖onInterceptTouchEvent,在事件属于BottomSheet返回true和调用dispatchTouchEventBottomSheet,该功能可以防止NestedScrollView滚动,但BottomSheet不能滚动本身并单击事件BottomSheet孩子没有工作了.

这是我的布局:

<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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
tools:ignore="UnusedAttribute">

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

<android.support.v4.widget.NestedScrollView
    android:id="@+id/nested"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="?actionBarSize"
    android:background="#ff0"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:id="@+id/ll1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingTop="24dp">

        <Button
            android:id="@+id/button_1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="8dp"
            android:background="@android:color/holo_green_dark"
            android:padding="16dp"
            android:text="Button 1"
            android:textColor="@android:color/white"/>

        <Button
            android:id="@+id/button_2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="8dp" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-coordinatorlayout android-nestedscrollview bottom-sheet

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

在 SQLite 中保存重新排序的 RecyclerView

所以我试图Drag-and-Drop在我的待办事项列表应用程序中实现,但是我在保存移动后的行顺序时遇到了麻烦 - 即我移动了项目,退出了应用程序,然后它恢复到原来的位置。我想到了一个解决办法。

我的解决方案:

在我的表中创建一列:specification_position。每次移动一行时,该onItemMove()方法都会返回 afromPositiontoPosition。将行的位置移动到toPosition,然后增加/更新那里和上面的所有值。每次读取表格时,它都会检查头寸并根据它对它们进行排序。

我的问题:

我的解决方案是否正确?有没有更好,更简单的方法来代替这样做?非常感谢!

sqlite android android-recyclerview

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

从活动中膨胀片段

这是我的活动课。我正在尝试将片段膨胀到此活动。

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.fg1, new ButtonsFragment());
        ft.commit();
    }
Run Code Online (Sandbox Code Playgroud)

活动_main.xml

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

    <fragment
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_margin="10dp"
        android:id="@+id/fg1"
        />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

ButtonsFragment.java

public class ButtonsFragment extends Fragment {

    Button b1,b2,b3;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
    {
        super.onCreateView(inflater,container,savedInstanceState);

       View v = inflater.inflate(R.layout.fragment_buttons,container,false);

        b2 = (Button)v.findViewById(R.id.b2);
        b1 = (Button)v.findViewById(R.id.b1);
        b3 = (Button)v.findViewById(R.id.b3);
        return v;
    }
}
Run Code Online (Sandbox Code Playgroud)

fragment_buttons.xml

<FrameLayout 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" …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

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

在调用超类构造函数方法之前检查子类中的条件

正如我们在子类的构造函数体中所知,父构造函数必须是第一个语句,否则我们会得到编译时错误.这里已经讨论过这个主题.

让我们假设调用父构造函数会导致系统资源成本过高.另一方面,在子类构造函数中我们需要首先检查一些条件,如果条件满足,我们很好地通过父构造函数,那么就没有必要更进一步(假设抛出异常):

class parent {
    parent(Object blah) {
        //Heavy resource consuming tasks
    }
}

class child extends parent {
    child(Object blah, boolean condition) {
        if (!condition) throw new IllegalArgumentException("Condition not satisfied");
        super(blah); //Compile error!
    }
}
Run Code Online (Sandbox Code Playgroud)

如果有人有同样的问题,我很好奇无论如何要处理这种情况,或者我必须先调用父构造函数,无论浪费多少资源然后抛出异常?

java inheritance constructor

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

在 RemoteViews 中启动动画

我用自定义视图做了一个通知,我需要在其中一个孩子上运行动画,但正如你所知RemoteViews,不允许直接访问所需的视图(start在其背景上调用方法),有谁知道如何访问视图或在其可绘制对象上调用提到的方法?
谢谢

notifications android android-remoteview

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