我有RegisterPage和LoginPage.当应用程序运行时,它将检查应用程序是否是第一次运行RegisterPage.如果它是第一次运行并且button未单击保存,则它将进入RegisterPage.如果它第二次运行但是从不点击保存按钮,它也会保留RegisterPage.否则就会去LoginPage.
这是我更新的代码
寄存器
appGetFirstTimeRun();
boolean clicked=false;
buttonSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clicked=true;
int appCurrentBuildVersion = BuildConfig.VERSION_CODE;
SharedPreferences appPreferences = getSharedPreferences("MyAPP", 0);
appPreferences.edit().putInt("app_second_time",
appCurrentBuildVersion).apply();
String name = editTextName.getText().toString();
String pass = editTextPassword.getText().toString();
String confirm = editTextConfirm.getText().toString();
if ((editTextName.getText().toString().trim().length() == 0) || (editTextPassword.getText().toString().trim().length() == 0) || (editTextConfirm.getText().toString().trim().length() == 0)) {
Toast.makeText(getApplicationContext(), "Field cannot be null", Toast.LENGTH_LONG).show();
}
else
{
insertData(name, pass, imageUri); // insert …Run Code Online (Sandbox Code Playgroud) 如何在 Kotlin 中转换Array<String>为ArrayList<String>?
var categoryList : ArrayList<String>?=null
val list = arrayOf("None", "ABC")
categoryList = ArrayList(Arrays.asList(list))
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
错误
Type inference failed. Expected type mismatch: inferred type is kotlin.collections.ArrayList<Array<String>!> /* = java.util.ArrayList<Array<String>!> */ but kotlin.collections.ArrayList<String>? /* = java.util.ArrayList<String>? */ was expected
Run Code Online (Sandbox Code Playgroud) 如何将时间转换为 am/pm ?
我有这个输出
I/flutter (17720): 9:00:00
I/flutter (17720): 11:00:00
I/flutter (17720): 12:00:00
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的
final item = snapshot.data[index];
print("Time " + item['time'].toString());
DateTime dateTime = DateTime.parse(item['time'].toString());
print(DateUtil().formattedTime(dateTime));
Run Code Online (Sandbox Code Playgroud)
日期工具
String formattedTime(DateTime dateTime) {
return DateFormat().add_jm().format(dateTime);
}
Run Code Online (Sandbox Code Playgroud)
错误
I/flutter (17720): 时间 09:00:00
????????? 小部件库捕获的异常 ??????????????????????????????????????? 以下 FormatException 被抛出 building Tags(dirty, state: TagsState#b3a2f): Invalid date format 09:00:00