主要问题是2-3秒后出现闪屏.在启动屏幕之前,会出现我不想要的空白布局.否则运行正常.只想删除在启动页面之前出现的空白布局.
主要活动:
public class MainActivity extends Activity {
private static String TAG = MainActivity.class.getName();
private static long SLEEP_TIME = 5; // Sleep for some time
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Removes notification bar
setContentView(R.layout.activity_main);
// Start timer and launch main activity
IntentLauncher launcher = new IntentLauncher();
launcher.start();
}
private class IntentLauncher extends Thread {
@Override
/**
* Sleep for some time and than start new activity.
*/
public void run() …
Run Code Online (Sandbox Code Playgroud) import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { ModalController, NavParams } from '@ionic/angular';
import { SelecttopicPage } from '../selecttopic/selecttopic.page';
import { ActionSheetController } from '@ionic/angular';
import { Platform } from '@ionic/angular';
import { Storage } from '@ionic/storage';
import { MediaCapture, MediaFile, CaptureError, CaptureVideoOptions } from '@ionic-native/media-capture';
import { Media } from '@ionic-native/media';
import { File } from '@ionic-native/file';
import { Diagnostic } from '@ionic-native/diagnostic';
import { AndroidPermissions } from …
Run Code Online (Sandbox Code Playgroud)我正在尝试使用DOT NET webservice将我的Android应用程序连接到我的计算机中的MySql数据库(localhost).我只能使用单个输入(EditText)连接到在线数据库.这里有3个EditText输入参数,数据库仅存在于计算机中.Web服务接收3个参数并检查3个输入是否与数据库中的相同.如果是,则返回一个值,如果否,则返回另一个值.我只是想将返回值(响应)保存到TextView.
LoginService.asmx
[WebService(Namespace = "Check_Activity")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class LoginService
{
MySqlConnection objCon = new MySqlConnection(ConfigurationManager.ConnectionStrings["ActiveConnection"].ConnectionString);
MySqlCommand objSqlCmd;
MySqlParameter objSqlParam;
[WebMethod]
public string LoginStatus(string uid, string pswrd, string category)
{
string returndata = "";
try
{
if (objCon.State != ConnectionState.Open)
{
objCon.Open();
}
objSqlCmd = new MySqlCommand("rawProcedure", objCon);
objSqlCmd.CommandType = CommandType.StoredProcedure;
objSqlCmd.Parameters.AddWithValue("UID", uid);
objSqlCmd.Parameters.AddWithValue("PASS", pswrd);
objSqlCmd.Parameters.AddWithValue("CAT", category);
objSqlParam = new MySqlParameter();
objSqlParam.ParameterName = "Response";
objSqlParam.MySqlDbType = MySqlDbType.VarChar;
objSqlParam.Direction = ParameterDirection.Output;
objSqlCmd.Parameters.Add(objSqlParam);
objSqlCmd.ExecuteNonQuery();
objCon.Close();
returndata = objSqlParam.Value.ToString();
return …
Run Code Online (Sandbox Code Playgroud)我正在使用volley来获取API的响应,但响应包含STATE_ID:STATE_NAME对(i.e. value:value pair)
,我需要在不同的字符串中使用双方的值.我需要将这些值放入微调器中,以便当用户选择时State
我也可以获得相应的ID.
// JSON response
{
"1": "West bengal",
"3": "Himachal Pradesh",
"4": "Maharashtra",
"11": "Queensland"
}
Run Code Online (Sandbox Code Playgroud)
我的守则
public class MainActivity extends AppCompatActivity {
private static final String STATE = "MY_API";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void login(View v){
loginRequest();
}
private void loginRequest() {
StringRequest stringRequest = new StringRequest(Request.Method.POST, STATE,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(MainActivity.this, response, Toast.LENGTH_SHORT).show();
}
}, new Response.ErrorListener() {
@Override
public …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Firebase 集成到我的 android 应用中。我正在使用本教程。我更新了我的 sdk 管理器,添加google-services.json
并执行了网站中提到的所有操作。我仍然收到此Google Play services out of date
错误。我想获取设备令牌 ID,以便我可以在登录活动中将其发送到服务器。我还需要做些什么来获取设备令牌 ID?
显现
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="MY_PACKAGE">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:launchMode="singleTask"
android:theme="@style/MyTheme">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<activity android:name=".LoginActivity" android:theme="@style/AppTheme" android:label="@string/signin"/>
<activity android:name=".RegisterActivity" android:theme="@style/AppTheme" android:label="@string/cac"/>
<service android:name=".services.RegistrationIntentService" android:exported="false"/>
<service
android:name=".services.FCMMessageHandler"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".services.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application> …
Run Code Online (Sandbox Code Playgroud) 我正在使用MaterialDateTimePicker.我想禁用每个月的特定工作日(如星期日).它在这篇文章中提到我们可以使用这个库来做到这一点,但how to disable particular weekdays?
我当然可以使用可用的短代码来限制月数,但我不想限制几个月的数量,只是从选择中禁用工作日.
public class MainActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener {
private TextView dateTextView;
private CheckBox modeDarkDate;
private CheckBox vibrateDate;
private CheckBox dismissDate;
private CheckBox limitDates;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Find our View instances
dateTextView = (TextView)findViewById(R.id.date_textview);
Button dateButton = (Button)findViewById(R.id.date_button);
modeDarkDate = (CheckBox)findViewById(R.id.mode_dark_date);
vibrateDate = (CheckBox) findViewById(R.id.vibrate_date);
dismissDate = (CheckBox) findViewById(R.id.dismiss_date);
limitDates = (CheckBox) findViewById(R.id.limit_dates);
// check if picker mode is specified in Style.xml
modeDarkDate.setChecked(Utils.isDarkTheme(this, modeDarkDate.isChecked())); …
Run Code Online (Sandbox Code Playgroud) 我有一个按钮,我希望它具有通常的BACK按钮的相同功能.但是只是调用finish()并没有完成所需的操作.
我尝试调用onBackPressed()但它需要创建一个单独的方法.有解决方案吗
t1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
/*Intent i1=new Intent(getApplicationContext(), MainView.class);
startActivity(i1); */
//finish();
this.onBackPressed() ;
}
});
Run Code Online (Sandbox Code Playgroud) 我试图使edittext背景只是一条直线而不是平常.我使用了自定义可绘制的形状.但是,该行将添加到edittext的中间,而不是作为常规的edittext行添加到底部.此外,当我按Enter键时,它不会保持在光标下方.有什么好办法吗?
定制抽屉:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#FA58AC"
android:width="1dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud) 通过Web服务进行后台工作时,我正在使用此库作为进度指示器。我想在进度条显示时使背景透明。有什么方法可以像在进度对话框中一样以编程方式使窗口透明吗?
public class MainActivity extends AppCompatActivity{
private EditText email, pass;
private SessionManager session;
private SQLiteHandler db;
private AVLoadingIndicatorView pb;
private static final String LOGIN = "http://ubooktoday.com/android/login";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
email = (EditText)findViewById(R.id.et1);
pass = (EditText)findViewById(R.id.et2);
session = new SessionManager(getApplicationContext());
db = new SQLiteHandler(getApplicationContext());
pb = new AVLoadingIndicatorView(this);
if (session.isLoggedIn()) {
startActivity(new Intent(MainActivity.this, ListVActivity.class));
finish();
}
}
public void login(View view){
if (!email.getText().toString().equals("") && !pass.getText().toString().equals("")) {
loginRequest();
}else{
Toast.makeText(getApplicationContext(), "Please enter the details", Toast.LENGTH_SHORT).show(); …
Run Code Online (Sandbox Code Playgroud)LogCat error:
FATAL EXCEPTION: main
Process: com.sam.shoppingcart, PID: 31773
android.database.sqlite.SQLiteException: near "Beef": syntax error (code 1): , while compiling: SELECT KEY_NAME FROM shop WHERE KEY_NAME=Corned Beef
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:893)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:504)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1339)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1278)
at com.sam.shoppingcart.SQLiteHandler.ifExists(SQLiteHandler.java:63)
at com.sam.shoppingcart.CustomListAdapter$1.onClick(CustomListAdapter.java:77)
Run Code Online (Sandbox Code Playgroud)
我有一个使用带有“添加”和“删除”按钮的自定义适配器的列表视图。当单击“添加”按钮时,LV 项目的名称和价格将被添加到数据库中。我想在添加 LV 项目时检查 DB 中是否已经存在。为此,我在 DBHandler 中创建了 ifExists(Model model) 函数。但是现在点击添加按钮它给了我错误。我做错了什么?PS:我从这里得到了这个功能。
public class MainActivity extends AppCompatActivity {
private ListView listView;
private ArrayList<Model> mListData;
private CustomListAdapter adapter;
@Override
protected void …
Run Code Online (Sandbox Code Playgroud)