小编Chi*_*ani的帖子

使用Java更新DynamoDB中的项目

我要更新特定项目(行中只有一个数据),

如何更新DynamoDB中的项目?

login_id是我的主键。我传递了login_id和其他布尔值。我想根据该登录ID将布尔值设置为true。

我怎样才能做到这一点?

我尝试了这段代码。

LinkedHashMap inputHashMap = (LinkedHashMap) input;

        login_id = (String) inputHashMap.get("login_id");
        isUserVerified = (Boolean) inputHashMap.get("isUserVerified");

        DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient());

        Table tableUserDetails = dynamoDB.getTable(USER_DETAILS_TABLE);
        Table tableOtpStatus = dynamoDB.getTable(OTP_DETAILS_TABLE);

        UpdateItemSpec updateItemSpec = new UpdateItemSpec().withPrimaryKey("login_id", login_id);

        try{

            UpdateItemOutcome outcome = tableUserDetails.updateItem(updateItemSpec);
            System.out.println("UpdateItem succeeded:\n" + outcome.getItem().toJSONPretty());
        }catch(Exception e){
            System.err.println(e.getMessage());
        }
Run Code Online (Sandbox Code Playgroud)

在执行以上代码时,出现以下异常。

The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException;
Run Code Online (Sandbox Code Playgroud)

java amazon-dynamodb aws-lambda

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

Android match_parent无法按预期工作

在我的布局文件中,我使用root ScrollView和child LinearLayout.

我搜索了这个,但没有得到帮助.我在父视图和子视图中都设置了match_parent.

但是儿童观点有问题.

子视图不像父视图那样填充.

这是图像和xml代码.

在此输入图像描述

布局文件.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:CustomTextView="http://schemas.android.com/apk/res-auto"
    xmlns:CustomEditTextView="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#D3D6DB"
    android:orientation="vertical"
    tools:context=".tabs.MyTravelTab" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/card_background_new"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp" >

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="@dimen/field_height"
                    android:layout_weight="0.4"
                    android:gravity="left|center_vertical" >

                    <com.mymv.controls.CustomTextView
                        android:id="@+id/textGPS"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        CustomTextView:typeface="Roboto-Regular.ttf"
                        android:text="ABC"
                        android:textColor="@color/black"
                        android:textSize="12sp" />

                    <ToggleButton
                        android:id="@+id/gps_toggle"
                        android:layout_width="wrap_content"
                        android:layout_height="24dp"
                        android:layout_margin="5dp"
                        android:background="@drawable/gps_custom_toggle"
                        android:checked="false"
                        android:textOff=""
                        android:textOn="" />

                    <com.mymv.controls.CustomTextView
                        android:id="@+id/textManual"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        CustomTextView:typeface="Roboto-Regular.ttf"
                        android:text="DEF"
                        android:textColor="@color/black"
                        android:textSize="11sp" /> …
Run Code Online (Sandbox Code Playgroud)

android

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

如何以编程方式从设置中获取默认屏幕超时时间?

我想以编程方式获得默认屏幕超时。

我知道如何使用以下代码以编程方式设置屏幕超时。

android.provider.Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, <Value for Timeout>);
Run Code Online (Sandbox Code Playgroud)

但我无法从设置中获得默认屏幕超时。 在此处输入图片说明

android

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

如何动态更改@GET注释中的值?

我正在使用Retrofit从服务器下载 APK 文件。

下面是代码片段。

Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(Util.APK_DOWNLOAD_URL)
                .build();

        RetrofitInterface retrofitInterface = retrofit.create(RetrofitInterface.class);

        Call<ResponseBody> request = retrofitInterface.downloadFile();
        try {

            downloadFile(request.execute().body());

        } catch (IOException e) {

            e.printStackTrace();
            Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_SHORT).show();

        }
Run Code Online (Sandbox Code Playgroud)

public interface RetrofitInterface {

    @GET("development/filename.apk")
    @Streaming
    Call<ResponseBody> downloadFile();
}
Run Code Online (Sandbox Code Playgroud)

但有问题。

下载的 APK 总是不同的。所以

我怎样才能设置public static String一些

@GET(Utils.APK_FILE_NAME)
Run Code Online (Sandbox Code Playgroud)

在我的 Utils 类中

public static String APK_FILE_NAME = ""
Run Code Online (Sandbox Code Playgroud)

目前我正在得到

属性值必须是常量

android annotations retrofit

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

如何在Android中清除Ratingbar的比率?

我是安卓新手。我想知道如何清除 ratingbar 的评级。
我该怎么办?
在此处输入图片说明





请帮我...

android

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