我有一张桌子question_table
和一张桌子ImageButton
(后面).单击Back后,我需要从数据库中获取最后插入的记录.
我行包括下面的列:question
,optionA
,optionB
,optionC
,optionD
,和我需要的数据对我的使用Activity
.我在数据库中创建了一个方法,但它不起作用.
这是代码供参考:
MySQLiteHelper.java提取:
public List<ObjectiveWiseQuestion> getLastInsertQuestion()
{
// long index = 0;
List<ObjectiveWiseQuestion>LocwiseProfileList=new ArrayList<ObjectiveWiseQuestion>();
db = getReadableDatabase();
Cursor cursor = db.query(
"sqlite_sequence",
new String[]{"seq"},
"name = ?",
new String[]{TABLE_QUESTION},
null,
null,
null,
null );
if (cursor.moveToFirst())
{
do {
ObjectiveWiseQuestion owq= new ObjectiveWiseQuestion();
owq.setQuestion(cursor.getString(2));
owq.setOptionA(cursor.getString(3));
owq.setOptionB(cursor.getString(4));
owq.setOptionC(cursor.getString(5));
owq.setOptionD(cursor.getString(6));
owq.setCorrectOption(cursor.getString(7));
LocwiseProfileList.add(owq);
} while(cursor.moveToNext());
db.close();
}
return LocwiseProfileList;
}
Run Code Online (Sandbox Code Playgroud)
OnClickListner …
在我们的Android应用程序中,我们需要创建一个浮动动作按钮,它不是默认的圆形,而是一个带有三个圆角的正方形.晶圆厂如下图所示:
我设法创建了这样一个表格,但不知道如何将它应用到我的工厂,或者甚至可能.该形状的xml文件如下所示:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/red" />
<corners
android:topLeftRadius="90dp"
android:topRightRadius="90dp"
android:bottomRightRadius="90dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
我试着改变形式
android:src="@drawable/my_shape"
Run Code Online (Sandbox Code Playgroud)
但这只会改变我按钮内的图标.我想我需要扩展FloatingActionButton,但我不知道如何.
有没有办法改变晶圆厂的形状?如果有人已经实现了这一点,我将很高兴看到一个样本.
调用activity.recreate(
) 时,黑屏(0.5 秒)。我不知道它来自哪里,因为它在其他设备上运行良好
我希望实现像这样的东西.带有两个编辑文本的浮动标签.我也使用TextInputLayout
过其他一些图书馆,但都只接受单身儿童EditText
.任何帮助表示赞赏.
两个编辑文本都必须是可聚焦的,并且提示从第二个上升.
android android-edittext material-design android-textinputlayout
我正在构建一个自定义电容器插件来获取用户的电话号码。我将电容器 3 与 Ionic 6 一起使用。
我找到了一个未被弃用的解决方案,并且是最近才获取用户的电话号码。
这是我获取电话号码的代码 -
private void requestHint() {
HintRequest hintRequest = new HintRequest.Builder()
.setPhoneNumberIdentifierSupported(true)
.build();
PendingIntent intent = Credentials.getClient(getActivity()).getHintPickerIntent(hintRequest);
IntentSenderRequest.Builder intentSenderRequest = new IntentSenderRequest.Builder(intent.getIntentSender());
hintLauncher.launch(intentSenderRequest.build());
}
ActivityResultLauncher<IntentSenderRequest> hintLauncher = registerForActivityResult(new ActivityResultContracts.StartIntentSenderForResult(),
result -> {
if(result!=null && result.getData()!=null){
Intent data = result.getData();
Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);
String phoneNum = credential.getId();
}
});
Run Code Online (Sandbox Code Playgroud)
但我在 Android Studio 上遇到错误“无法解析‘NumberPluginPlugin ’中的方法‘registerForActivityResult’”
我在这里缺少什么?根据网上一些人的建议,我添加了以下依赖项 -
implementation "androidx.fragment:fragment:1.4.1"
implementation "androidx.activity:activity:1.4.0"
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
Run Code Online (Sandbox Code Playgroud)
我仍然不确定这里出了什么问题。
我正在android studio中开发一个视频转换器.我能够成功转换文件,并可以播放生成的文件:
File file = new File(filepath);
Uri path = Uri.fromFile(file);
Intent Openintent = new Intent(Intent.ACTION_VIEW);
Openintent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Openintent.setDataAndType(path, "audio/mp3");
try {
startActivity(Openintent);
}
catch (ActivityNotFoundException e) {
}
Run Code Online (Sandbox Code Playgroud)
但我找不到任何代码来打开生成的文件夹并显示标记的转换文件.就像我们在windows中一样Locate file in folder
.
经审核,因违反政策已从 Google Play 下架。在您提交合规更新之前,用户将无法使用此应用。
问题:违反 Android 广告 ID 使用政策和开发者分发协议第 4.8 节
当应用请求或处理敏感的用户或设备信息时,Google Play 要求开发者提供有效的隐私政策。我们发现您的应用会收集和传输 Android 广告标识符,这受隐私政策要求的约束。如果您的应用收集了 Android 广告 ID,则您必须在 Play 管理中心的指定字段以及应用内提供有效的隐私政策。
后续步骤:提交您的应用以供再次审核
Read through the Usage of Android Advertising ID and User Data policies, as well as the Developer Distribution Agreement, and make appropriate changes to your app. If you decide to collect sensitive user information, be sure to abide by the above policies, and include a link to a valid privacy policy on your app's store listing page and …
Run Code Online (Sandbox Code Playgroud) 我正在尝试 hilt,我想注入 moshi 进行序列化和反序列化。
以下是来自 github Repo 的代码示例,该示例未使用 di:
open class InfoTypeConverter {
private val moshi = Moshi.Builder().build() //not using dependency injection
@TypeConverter
fun fromString(value: String): PokemonInfo.Type? {
val adapter: JsonAdapter<PokemonInfo.Type> = moshi.adapter(PokemonInfo.Type::class.java)
return adapter.fromJson(value)
}
@TypeConverter
fun fromInfoType(type: PokemonInfo.Type): String {
val adapter: JsonAdapter<PokemonInfo.Type> = moshi.adapter(PokemonInfo.Type::class.java)
return adapter.toJson(type)
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试随机的东西来现场注入,就像 @AndroidEntryPoint/@EntryPoint 的注释一样,显然它不起作用。
我正在使用Espresso进行仪器测试并在Android Preview P Emulator上运行它们.我在我的测试类中有5个测试用例,其中一个测试在运行测试套件时失败并得到以下错误.
检测到API兼容性问题
失败的测试用例是在单独运行而不是在套件中运行时.
由于对话框显示在显示的视图上Detected problems with API compatibility
,因此在层次结构异常中找不到匹配的视图以及上述错误.
我正在尝试通过遵循本文实现对我的android应用程序的启动屏幕 。我已逐步遵循它,但是每当我尝试运行该应用程序时,它都会立即崩溃,并且在logcat中出现以下错误:
2019-01-05 10:46:33.682 2265-2265/com.example.khoi.parkingapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.khoi.parkingapp, PID: 2265
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.khoi.parkingapp/com.example.khoi.parkingapp.SplashActivity}: android.content.res.Resources$NotFoundException: Drawable com.example.khoi.parkingapp:drawable/splash_background with resource ID #0x7f07008d
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2955)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: android.content.res.Resources$NotFoundException: Drawable com.example.khoi.parkingapp:drawable/splash_background with resource ID #0x7f07008d
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/splash_background.xml from drawable resource ID #0x7f07008d
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:837)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:659)
at android.content.res.Resources.getDrawableForDensity(Resources.java:891)
at android.content.res.Resources.getDrawable(Resources.java:833)
at android.content.Context.getDrawable(Context.java:605)
at …
Run Code Online (Sandbox Code Playgroud)