小编Psy*_*her的帖子

Android倒数计时器解释通缉

在android参考资料中我发现了一个关于countdowntimers的页面: CountDownTimers

它里面有这段代码:

    new CountDownTimer(30000, 1000) {

     public void onTick(long millisUntilFinished) {
         mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
     }

     public void onFinish() {
         mTextField.setText("done!");
     }
  }.start();
Run Code Online (Sandbox Code Playgroud)

我想知道它是什么,以及它是一个对象或类,以及如何将它用作不同类对象的计时器.有人可以解释我将如何把它放入我的android项目并使用它.谢谢.

android countdowntimer

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

Sqlite异常,语法错误

我还在学习Android开发,我在创建一个sqlite数据库表时遇到了问题.这是我的代码的一部分:

`

private static final String CREATE_ADS_PICTURE = "CREATE TABLE "
        + AdsBDD.TABLE_ADS_PICTURE + "(" + AdsBDD.ID_PICS
        + " INTEGER PRIMARY KEY AUTOINCREMENT ," + AdsBDD.AD_ID
        + " INTEGER NOT NULL," + AdsBDD.PICTURE + " TEXT," + AdsBDD.FOLDER
        + " TEXT," + AdsBDD.ORDER_NO + " INTEGER NOT NULL);";

private static final String CREATE_AGENCES = "CREATE TABLE "
        + AgencesBDD.TABLE_AGENCES + "(" + AgencesBDD.ID
        + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," + AgencesBDD.GROUP
        + " INTEGER," + AgencesBDD.USERNAME + " …
Run Code Online (Sandbox Code Playgroud)

sqlite android syntax-error

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

片段隐藏在后退按钮后

我在活动中添加了一个片段,使用下面的代码:

    FragmentManager fragmentManager=getFragmentManager();
    FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
    PreferenceFragment preferencefragment=new Preferencefragment();
    fragmentTransaction.add(R.id.maincontainer, preferencefragment);
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commit();
Run Code Online (Sandbox Code Playgroud)

布局文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<DigitalClock
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/digitalClock"
    android:layout_gravity="center"
    android:textColor="@color/appcolor"
    android:layout_centerHorizontal="true"
    style="@android:style/TextAppearance.DeviceDefault.Large"
    android:textSize="45dp"/>
<TimePicker
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/timePickersms" />

<FrameLayout
    android:id="@+id/maincontainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
Run Code Online (Sandbox Code Playgroud)

活动有数字时钟和时间戳,下面显示片段,现在当我点击后退按钮时,片段消失,之后显示上一个活动.如何一次显示以前的活动?

我的下一个问题是如何在屏幕上按下按钮时刷新片段?

android android-layout android-fragments

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

Android openOptionsMenu在KitKat中什么都不做

我有一个openOptionsMenu()来自Activity的方法的按钮,它在其他Android版本上运行良好,但在KitKat上它绝对没有...为什么?

android android-optionsmenu android-4.4-kitkat

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

无法使用appcompact v7和Android Studio 1.1 Preview更改操作栏的颜色

我尝试了很多样式来改变动作栏的颜色,但没有奏效.

这是我的风格:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="actionBarStyle">@style/AppTheme.ActionBarStyle</item>
</style>
 <style name="AppTheme.ActionBarStyle" parent="Widget.AppCompat.ActionBar.Solid">
    <item name="android:background">#f01234</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我的模拟器版本:Android 4.2

android android-theme android-actionbar

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