小编Jéw*_*ôm'的帖子

在Android Studio中创建aar文件

我想在Android Studio中为我的库创建一个aar文件,我会选择jar选项,但我的库有资源.

知道如何从库中创建aar文件吗?

android jar android-studio aar

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

不推荐使用ActionBarActivity

实际上没有问题.项目编译和运行.但我无法理解什么是三角触发类的名称(Android Studio告诉我们使用了弃用的代码)在此输入图像描述.谁能解释一下?

android deprecated android-actionbar android-studio

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

Android Studio没有看到genymotion

我更新了0.5到0.8.14版本的android studio,但是现在工作室没有看到genymotion,我现在必须做什么?谢谢大家.

编辑:我也通过更新genymotion解决了这个问题

android android-studio genymotion

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

为什么可以在Kotlin的课堂外写一个函数?

我不明白为什么可以在Kotlin的课堂外写一个函数?这是一个好习惯吗?

例如,在Kotlin中可以在我的MainActivity课外编写一个函数:

fun hello(){}

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        hello()
    }
}
Run Code Online (Sandbox Code Playgroud)

在Java中,这是不可能的!这不是面向对象语言如何正常工作,对吧?

在文档中,他们讨论了经典函数的本地函数和类或对象中定义的函数的成员函数,但它们没有解释何时使用其中一个或哪一个更好.

java android kotlin

25
推荐指数
3
解决办法
3627
查看次数

在各种Activity中使用相同的onTouchEvent

我正在使用onTouchEventfor for MainActivity.class.它工作正常:如果用户用手指制作双L,我称之为片段.我想onTouchEvent在另一个中使用它,Activity但我认为如果我复制我的所有代码都很脏.

为此我已经TouchListenerImpl为此创建了一个工具:

class TouchListenerImpl implements View.OnTouchListener {

    private boolean movingDownL, movingDownR, movingLeft, movingRight, movingSuccessL, movingSuccessR = false;
    private Point oldCoordsL, oldCoordsR, startPointL, startPointR = new Point(0, 0);
    private boolean admin_touch = false;
    private OnLTouch callback;

    void setCallback(OnLTouch c) {
        callback = c;
    }

    interface OnLTouch {
        void lTouchSuccess();
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {

        Log.d("debugTouch", "onTouch");

        int pIndexL = event.findPointerIndex(event.getPointerId(0));
        int pIndexR = 0;

        if(event.getPointerCount() > …
Run Code Online (Sandbox Code Playgroud)

android ontouchlistener

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

使用Android 7的FileUriExposedException

当我尝试捕获图片时出现此错误:

致命异常:主要android.os.FileUriExposedException:file:///storage/emulated/0/fname_1498727381241.jpg通过在android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)的ClipData.Item.getUri()暴露超出应用程序在Android.content.Intent.prepareToLeaveProcess(Intent.java:)的android.content.ClipData.prepareToLeaveProcess(ClipData.java:835)的android.net.Uri.checkFileUriExposed(Uri.java:2346)9514)android.actent.Intent.prepareToLeaveProcess(Intent.java:9499)在android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)的android.app.Activity.startActivityForResult(Activity.java:4403). app.Activity.startActivityForResult(Activity.java:4362)位于android.view.View的opteamit.com.belami.CommuniquerPartagerPhotosActivity $ 1.onClick(CommuniquerPartagerPhotosActivity.java:46).performClick(View.java:6261)在android.view.Handler.dispatchMessage(Handler)的android.view.View $ PerformClick.run(View.java:23752)android.os.Handler.handleCallback(Handler.java:751) .java:95)在android.app.Looper.loop(Looper.java:154)的android.app.ActivityThread.main(ActivityThread.java:6776)java.lang.reflect.Method.在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)的com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1496)中调用(Native Method)

它以前工作但似乎问题是因为我使用Android 7(API 24).

这是我的代码:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                imageUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "fname_" +
                        String.valueOf(System.currentTimeMillis()) + ".jpg"));
                intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
Run Code Online (Sandbox Code Playgroud)

android android-7.0-nougat

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

将我付费应用的所有用户迁移到应用内购买

实际上,我有2个应用程序:免费和付费(专业版).我想将我的2个应用程序迁移到带有应用程序内购买的免费应用程序.

我可以保存所有人在我的应用内购买中如何支付专业版吗?最好的方法是什么?

android google-play

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

使用 Kotlin 协程了解 Job 的所有状态

是否可以知道一个协程Job的所有状态?

我找到了这个函数扩展,但我无法访问 a 的所有状态Job

fun Job.status(): String = when {
    isCancelled -> "cancelled"
    isActive -> "Active"
    isCompleted -> "Complete"
    else -> "Nothing"
}
Run Code Online (Sandbox Code Playgroud)

该类没有isNew,isCancellingisWaitingForChildren函数Job。为什么 ?

在此输入图像描述

coroutine kotlin kotlin-android-extensions kotlin-coroutines

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

使用数据绑定设置 ImageView 的色调

我使用数据绑定来设置我的ImageView. 这运行良好:

android:tint="@{plantEntity.isFavorite ? @color/favorite : @color/favorite_none}" />
Run Code Online (Sandbox Code Playgroud)

问题是android:tint已弃用。当我尝试使用时app:tint,出现此错误:

Cannot find a setter for <android.widget.ImageView app:color> that accepts parameter type 'int'

If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.
Run Code Online (Sandbox Code Playgroud)

为什么以及我必须做什么?创建一个BindingAdapter?

android android-databinding

6
推荐指数
3
解决办法
1435
查看次数

使用 maxLines 选取框

如何使用 MaxLines 而不是 SingleLine 来制作选取框?

这是我的 TextView :

<TextView
    android:text="bla bla bla bla bla bla"
    android:id="@+id/MarqueeText" 
    android:layout_width="30dp"
    android:layout_height="wrap_content" 
    android:singleLine="true"
    android:ellipsize="marquee" 
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:freezesText="true">
Run Code Online (Sandbox Code Playgroud)

在我的 code.java 之后setSelectedTextView

TextView txtView=(TextView) findViewById(R.id.MarqueeText);
txtView.setSelected(true);
Run Code Online (Sandbox Code Playgroud)

问题是android:singleLine已被弃用,所以我必须使用android:maxLines它,但选框不适用于它。

android ellipsis textview

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