在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开发,我在创建一个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) 我在活动中添加了一个片段,使用下面的代码:
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)
活动有数字时钟和时间戳,下面显示片段,现在当我点击后退按钮时,片段消失,之后显示上一个活动.如何一次显示以前的活动?
我的下一个问题是如何在屏幕上按下按钮时刷新片段?
我有一个openOptionsMenu()来自Activity的方法的按钮,它在其他Android版本上运行良好,但在KitKat上它绝对没有...为什么?
我尝试了很多样式来改变动作栏的颜色,但没有奏效.
这是我的风格:
<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