小编Cha*_*dru的帖子

使用RSA公钥的Android加密字符串

我正在一个项目中工作,我必须使用RSA公钥加密密码.我从SO那里尝试了很多样品和解决方案,如下所示

  1. 来自公共字符串的Android RSA加密

  2. RSA使用SpongyCastle

但不幸的是,没有一个解决方案适用于我的案例.如果我尝试任何解决方法,我会反复跟踪异常

错误日志:

04-21 07:50:57.876 18842-18842/com.takeoffandroid.passwordencryption W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
04-21 07:50:57.986 18842-18842/com.takeoffandroid.passwordencryption W/System.err: java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error:0c0890ba:ASN.1 encoding routines:asn1_check_tlen:WRONG_TAG
04-21 07:50:57.986 18842-18842/com.takeoffandroid.passwordencryption W/System.err:     at com.android.org.conscrypt.OpenSSLKey.getPublicKey(OpenSSLKey.java:250)
04-21 07:50:57.987 18842-18842/com.takeoffandroid.passwordencryption W/System.err:     at com.android.org.conscrypt.OpenSSLRSAKeyFactory.engineGeneratePublic(OpenSSLRSAKeyFactory.java:47)
04-21 07:50:57.987 18842-18842/com.takeoffandroid.passwordencryption W/System.err:     at java.security.KeyFactory.generatePublic(KeyFactory.java:172)
04-21 07:50:57.987 18842-18842/com.takeoffandroid.passwordencryption W/System.err:     at com.takeoffandroid.passwordencryption.MainActivity.RSAEncrypt(MainActivity.java:181)
04-21 07:50:57.987 18842-18842/com.takeoffandroid.passwordencryption W/System.err:     at com.takeoffandroid.passwordencryption.MainActivity.onCreate(MainActivity.java:80)
04-21 07:50:57.987 18842-18842/com.takeoffandroid.passwordencryption W/System.err:     at android.app.Activity.performCreate(Activity.java:6532)
04-21 07:50:57.987 18842-18842/com.takeoffandroid.passwordencryption W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
04-21 07:50:57.987 …
Run Code Online (Sandbox Code Playgroud)

encryption android rsa bouncycastle spongycastle

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

如何更改前Lollipop和Lollipop版本的工具栏菜单项文本颜色

我在我的应用程序中使用工具栏进行材料设计.一切正常,但除了改变菜单项文字颜色,我完全坚持解决方案.我还发布了应该采取的文本的截图和我在我的应用程序中使用的代码供您参考.我尝试了几种替代方法,例如分配如下

<item name="android:actionMenuTextColor">@color/white</item>

<item name="android:textColor">#000</item>
Run Code Online (Sandbox Code Playgroud)

但是已知上述解决方案对我有用.

要求截图:

在此输入图像描述

需要将SKIP菜单项从黑色更改为白色.

styles.xml

<style name="ToolBarTheme" parent="@style/Theme.AppCompat.Light">
        <item name="colorPrimary">@color/blue</item>
        <item name="colorPrimaryDark">@color/blue</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        <item name="android:actionMenuTextColor">@color/white</item>
        <item name="android:textColor">#000</item>

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

toolbar.xml

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways"
    android:fitsSystemWindows="true"
    android:background="?attr/colorPrimary"/>
Run Code Online (Sandbox Code Playgroud)

舱单

<activity
            android:name=".activity.HomeActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboard|screenLayout|orientation"
            android:theme="@style/ToolBarTheme"></activity>
Run Code Online (Sandbox Code Playgroud)

我真的不知道我犯了什么错误.请帮我.提前致谢

android menuitem android-menu material-design android-toolbar

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

在 Recycler GridLayoutManager 中为 3 和 4 行项目提供更多间距

我使用 RecyclerView 和 GridLayoutManager 作为巴士票预订的布局。一切正常,但除了我坚持使用逻辑的地方,我必须使用这些逻辑在所有行中的 3 和 4 列项目之间留出更多间距。基本上我的布局应该像下面所附的屏幕截图。

我的要求:

在此处输入图片说明

电流输出:

在此处输入图片说明

我还发布了我完整的 RecyclerView GridLayoutManager 供您参考,如下所示

MultiSelectRecyclerViewAdapter.java

public class MultiSelectRecyclerViewAdapter extends SelectableAdapter<MultiSelectRecyclerViewAdapter.ViewHolder> {

    private ArrayList<String> mArrayList;
    private Context mContext;
    private ViewHolder.ClickListener clickListener;



    public MultiSelectRecyclerViewAdapter (Context context, ArrayList<String> arrayList,ViewHolder.ClickListener clickListener) {
        this.mArrayList = arrayList;
        this.mContext = context;
        this.clickListener = clickListener;

    }

    // Create new views
    @Override
    public MultiSelectRecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                             int viewType) {

        View itemLayoutView = LayoutInflater.from(parent.getContext()).inflate(
                R.layout.row_multiselect, null);

        ViewHolder viewHolder = new ViewHolder(itemLayoutView,clickListener);

        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder viewHolder, …
Run Code Online (Sandbox Code Playgroud)

android android-custom-view gridlayoutmanager android-recyclerview

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

如何自定义列表视图以便为行项目的第一个和第二个位置设置不同的布局?

我正在开发一个项目,我需要为每个行项目定制不同布局的列表视图,如下所示
(i)行项目中的第一个位置应该是正常的imageviewtextview
(ii)行项目中的第二个位置应该是水平 列表视图
(iii)连续第三个位置itme应该是普通的自定义 列表视图

我知道所有这些事情要单独做,但我不知道如何通过仅更改行项目位置继续合并到单个列表视图.我的确切要求的形象是在此输入图像描述.
另外,我正在为您分享自定义listview适配器类的一些代码供您参考

public class ListViewAdapter extends BaseAdapter {

    // Declare Variables
    Context context;

    String[] country;
      int[] flag;
    LayoutInflater inflater;

    public ListViewAdapter(Context context, String[] country, int[] flag) {
        this.context = context;
        this.country = country;
        this.flag = flag;
    }

    @Override
    public int getCount() {
        return country.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    public View getView(int position, View …
Run Code Online (Sandbox Code Playgroud)

android listview android-custom-view android-listview baseadapter

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