小编Jun*_*urg的帖子

如果按钮是ACTION_DOWN,是否可以强制按住1秒钟?

按住当前按钮(ACTION_DOWN)以获得按下时的当前时间.当我释放按钮(ACTION_UP)时,也会拍摄当前时间,并按时间差剪切和粘贴音频文件.如果用户按下并释放按钮太快,则会生成无效的音频文件.所以我想实现无条件按压超过1秒的功能.

按钮ACTION_DOWN,ACTION_UP有没有办法在动作事件中实现这样的功能?如果你知道,请帮我个忙.以下是触摸侦听器的源代码.

recordBtn.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction()) {
                case MotionEvent.ACTION_DOWN: {
                    long currentDuration = vAudioPlayer.getCurrentDuration();
                    // ?? ?? ( combineList ???? ??? ? )
                    if (mRecordThread != null) {
                        if (combineList.size() % 2 == 0) {
                            mRecordThread.startFileWrite(currentDuration);
                            combineList.add(currentDuration);
                        }
                    }
                }

                // ??, ??? ? ?????
                micBg1.setVisibility(View.VISIBLE);
                micBg2.setVisibility(View.VISIBLE);

                micBg1.startAnimation(animMic1);
                micBg2.startAnimation(animMic2);

                //userImg.setImageBitmap(userImgBitmap);
                userImg.startAnimation(animZoomIn);
                // artistImg.setImageBitmap(artistBlurImg);
                artistImg.startAnimation(animZoomOut);

                break;
                case MotionEvent.ACTION_UP: {
                    long currentDuration = vAudioPlayer.getCurrentDuration();
                    if (mRecordThread != null) {
                        // ??? ?? ( …
Run Code Online (Sandbox Code Playgroud)

android action button motion

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

关于Android Firebase检索数据(无setter/字段错误)

我只想从firebase数据库中检索数据,但我不知道获取该数据的正确方法。这是我在 android studio 中的错误:

  W/ClassMapper: No setter/field for chapterTwo found on class 
  com.junburg.moon.rockbottom.model.Chapter
  W/ClassMapper: No setter/field for chatperOne found on class 
  com.junburg.moon.rockbottom.model.Chapter
  W/ClassMapper: No setter/field for chapterTwo found on class 
  com.junburg.moon.rockbottom.model.Chapter
  W/ClassMapper: No setter/field for chapterOne found on class 
  com.junburg.moon.rockbottom.model.Chapter
Run Code Online (Sandbox Code Playgroud)

这是我的数据类。这是一个Chapter.class模型。

public class Chapter {

    private String chaterName;
    private String chaterExplain;

    public Chapter() {
    }

    public Chapter(String chaterName, String chaterExplain) {
        this.chaterName = chaterName;
        this.chaterExplain = chaterExplain;
    }

    public String getChaterName() {
        return chaterName;
    }

    public …
Run Code Online (Sandbox Code Playgroud)

java android firebase firebase-realtime-database

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

如何在 Kitkat 中设置应用栏背景颜色的底部

我尝试将底部应用栏背景颜色设置为透明。但在 Kitkat 中,底部应用栏背景颜色未正确分配。在 Kitkat 中,底部应用栏背景颜色为白色。如何根据需要设置底部应用栏背景颜色?

我不明白“背景”和“backgroundTint”。请让我知道这一点。

谢谢。

这是我的 xml 代码。

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

    <android.support.v7.widget.RecyclerView
        android:id="@+id/circle_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.bottomappbar.BottomAppBar
        android:id="@+id/main_bottom_app_bar"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:layout_gravity="bottom"
        android:backgroundTint="@color/view_transparent"
        app:fabAlignmentMode="center"
        app:fabCradleRoundedCornerRadius="2dp"
        app:hideOnScroll="true">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="?actionBarSize"
            android:background="@android:color/transparent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="?actionBarSize"
                android:background="@android:color/transparent"
                android:layout_toLeftOf="@id/empty_view"
                android:gravity="center_vertical">

                <LinearLayout
                    android:id="@+id/main_catalogue_btn"
                    android:layout_width="56dp"
                    android:layout_height="56dp"
                    android:layout_centerInParent="true"
                    android:background="@android:color/transparent"
                    android:gravity="center_vertical"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/catalogue_img"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        app:srcCompat="@drawable/ic_format_list_bulleted_white_24dp" />

                    <TextView
                        android:id="@+id/catalogue_txt"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Catalogue"
                        android:textColor="@android:color/white"
                        android:textSize="12dp" />
                </LinearLayout>
            </RelativeLayout>

            <View
                android:id="@+id/empty_view"
                android:layout_width="68dp"
                android:layout_height="?actionBarSize"
                android:layout_centerInParent="true" />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="?actionBarSize"
                android:background="@android:color/transparent"
                android:layout_toRightOf="@id/empty_view"
                android:gravity="center_vertical">

                <LinearLayout
                    android:id="@+id/main_info_btn"
                    android:layout_width="56dp"
                    android:layout_height="56dp"
                    android:layout_centerInParent="true"
                    android:background="@android:color/transparent" …
Run Code Online (Sandbox Code Playgroud)

android background tint colors bottomappbar

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

我可以使用背压完成2项活动

我在A活动上调用了B Activity.但B活动背景是透明的.所以我不能使用INTENT_FLAG.必须保留一项活动.

所以!

当我按下后退按钮如何一起完成2个活动?不使用INTENT_FLAG.

android android-activity

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