Problems encountered during the development of Android Studio

1. The exported APK cannot be installed on the andriod 6.0 version of the mobile phone, it shows that the application is not installed.
Solution: When
packaging the APK, check all V1 and V2. The
APK signature scheme v2 was introduced in Android 7.0 (Nougat). In order for the APK to be installed on Android 6.0 (Marshmallow) and lower devices, the APK should be signed using the JAR signature function, and then signed using the v2 scheme.

2. Regarding the problem of calling startactivityforresult in Fragment,
one sentence can be summarized, where startactivityforresult is called can be adjusted to onActivityResult

3. The bug that appears when refreshing the picture in RecylerView causes the picture not to be displayed after refreshing.
Solution:

  1. RecyclerView.RecycledViewPool pool =recycler_view.getRecycledViewPool();
    pool.setMaxRecycledViews(0,10);
    recycler_view.setRecycledViewPool(pool);
    2.myAdapter.notifyItemRangeChanged(0,Beans.size());
    4. Reprint edittext and click the blank space to hide Soft keyboard
    /**
  • 获取点击事件
    */
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
    View view = getCurrentFocus();
    if (isHideInput(view, ev)) {
    HideSoftInput(view.getWindowToken());
    view.clearFocus();
    }
    }
    return super.dispatchTouchEvent(ev);
    }

/**

  • 判定是否需要隐藏
    */
    private boolean isHideInput(View v, MotionEvent ev) {
    if (v != null && (v instanceof EditText)) {
    int[] l = {0, 0};
    v.getLocationInWindow(l);
    int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left + v.getWidth();
    if (ev.getX() > left && ev.getX() < right && ev.getY() > top && ev.getY() < bottom) {
    return false;
    } else {
    return true;
    }
    }
    return false;
    }

/**

  • 隐藏软键盘
    */
    private void HideSoftInput(IBinder token) {
    if (token != null) {
    InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    manager.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS);
    }

5. Recyclerview produces the problem of disordered item attributes.
If there is an if, there must be an else

6. Recylcrvice quickly pulls down to cause a crash when refreshing.
Two methods
1. Set the ontouchlistner of rlview to be non-slidable when refreshing so that it does not respond to sliding events
. 2. Go to clear the original list when requesting new data. The data.

Guess you like

Origin blog.csdn.net/adminyuqiao/article/details/104475042