小编Ken*_*rth的帖子

android资源中样式的文档

我试着在我的代码中为一些样式添加文档.问题是,android studio没有将文档直接链接到样式的用法.

我的意思是,简单的<! - Docu - >注释不会为样式创建我想要的文档.

<!-- Documentation -->
<style name="graph" parent="font_graph_base"/>
Run Code Online (Sandbox Code Playgroud)

这是我想要的,作为视图属性的示例: 查看属性示例

这就是我得到的,如果我使用简单的<! - - >注释,我想要的是填写此文档. 当前状态...

有没有办法让这个工作?

xml documentation android android-layout

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

使用先前启动的活动转换恢复活动时查看可见性状态丢失

说明:

  • 我从活动A开始活动B的活动B.

  • 启动新的活动B后,我更改了B中某些视图(View.GONE)的可见性状态.

问题是:

当启动新的活动C并返回活动B(或强制B中的onPause)时,具有更改的可见性状态的视图再次出现,而不会通过代码或其他方式触摸视图.

以下视频解释了图片中的问题:https://youtu.be/oqCZo5CSkQk

当不使用转换时,一切都按预期工作.有谁有想法,如何在恢复活动时防止视图状态丢失?我用ActivityOptionsCompat错了吗?

我使用支持库:

'com.android.support:support-v4:27.1.1''com.android.support:appcompat-v7:27.1.1'

但问题也出现在旧版本和不同的手机制造商(Pixel,三星等).

这里是重现问题的代码:

布局

活动A:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical">

  <TextView
      style="@style/TextAppearance.AppCompat.Title"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="24dp"
      android:gravity="center"
      android:text="Activity A | this starts the transition to another activity"/>

  <android.support.v7.widget.AppCompatImageView
      android:id="@+id/imageToAnimate"
      android:layout_width="20dp"
      android:layout_height="20dp"
      app:srcCompat="@android:drawable/star_big_on"/>

  <Button
      android:id="@+id/start_next_activity"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="30dp"
      android:text="start Another Activity"/>

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

活动B:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

  <TextView
      style="@style/TextAppearance.AppCompat.Title"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="24dp"
      android:gravity="center" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-activity

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

ORMLite在Android上将表从一个数据库插入另一个数据库的问题

我正在从服务器下载SQLite数据库文件到用户的Android设备.下载后,我使用下载的数据库插入或替换本地数据库中的一些表.我使用ORMLite 4.47.

首先,我将数据库文件附加到DatabaseConnection:

DatabaseConnection con = null;
con = conSrc.getReadWriteConnection();
con.executeStatement("attach database '" + localDatabase.getAbsolutePath() + "' as '" + localDb + "'", DatabaseConnection.DEFAULT_RESULT_FLAGS);
con.executeStatement("attach database '" + downloadedDatabase.getAbsolutePath() + "' as '" + remoteDb + "'", DatabaseConnection.DEFAULT_RESULT_FLAGS);
Run Code Online (Sandbox Code Playgroud)

附加数据库后,我创建以下查询以从下载的数据库(remoteDb)复制到本地数据库(localDb):

INSERT OR REPLACE INTO localDb.table_items (createdAt_device, updatedAt_device, _id, column_1, column_2, column_3, column_4, column_5, column_6) SELECT createdAt_device, updatedAt_device, _id, column_1, column_2, column_3, column_4, column_5, column_6 FROM remoteDb.table_items
Run Code Online (Sandbox Code Playgroud)

然后,我从ORMLite执行以下函数:

con.executeStatement(query, flags); 
Run Code Online (Sandbox Code Playgroud)

该功能在Android 4.1版(使用SQLite 3.7.11)及更高版本上运行良好.但是我在Android 4.0和4.0.3(使用SQLite 3.7.4)上遇到以下错误:

09-13 15:51:19.852: E/com.example.controller(1028): java.sql.SQLException: Problems executing INSERT …
Run Code Online (Sandbox Code Playgroud)

database sqlite android insert ormlite

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