小编Geo*_*gan的帖子

尝试在空对象引用上调用虚方法'android.view.Window $ Callback android.view.Window.getCallback()'

当我SplashActivity打开LoginActivity我的应用程序崩溃.

以下是我的SplashActivity.java:

package com.example.android.appName;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import java.util.Timer;
import java.util.TimerTask;

public class SplashActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            public void run() {
                Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                startActivity(intent);
                finish();
            }
        }, 1500);
    }
}
Run Code Online (Sandbox Code Playgroud)

和我的LoginActivity.java:

package com.example.android.appName;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; …
Run Code Online (Sandbox Code Playgroud)

java android findviewbyid

23
推荐指数
1
解决办法
6万
查看次数

无法保存该应用程序.请检查表格是否有错误.

我正在尝试在我的开发人员控制台中更新应用程序,但这是我在上传apk后尝试发布时遇到的错误.

无法保存该应用程序.请检查表单是否有错误.

android developer-console

17
推荐指数
2
解决办法
9946
查看次数

这是什么意思:'私有'修饰符与JLS建议无序

在将'final'添加到myItem声明之前,我首先收到此警告:

私人领域'myItem'可以成为最终的; 它只在声明或构造函数中初始化.

private Item myItem;
Run Code Online (Sandbox Code Playgroud)

添加最终后,这是我得到的警告:

"私有"修饰符与JLS建议无关.

final private Item myItem;
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么我得到这个?我做了一些研究,但似乎无法找到解决这个问题的任何东西.

java warnings field eclipse-plugin

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

如何让Async Task在Android中完成

我正在开发一个应用程序,它从网络中检索数据,将它们存储到设备然后读取它们.问题是,我在异步任务中得到我的数据..并且我的应用程序在尝试向用户显示数据之前不让任务完成..我已经尝试过task.get()但没有结果(它只是停止那里).

这是我的任务:

public GetOptionsTask(XMLPortalGetOptions request) {
        super(request);
    }
    protected void onCancelled(){
        // TODO afficher message pas d'options sur le disque
    }
    @Override
    public void handleError(Transaction transaction) {
        // TODO afficher message pas d'options sur le disque
    }
    @Override
    public void handleSuccess(Transaction transaction) {
        saveOptions(transaction.getResponse());
        request = null;
        Log.d(OptionsManager.class.getName(), this.getStatus().toString());
    }
Run Code Online (Sandbox Code Playgroud)

此任务是我的自定义异步任务的一个实例:

protected BaseXMLTransaction request;

public abstract void handleError(Transaction transaction);
public abstract void handleSuccess(Transaction transaction);
public TransactionTask(BaseXMLTransaction request){
    this.request = request;
}
@Override
protected Void doInBackground(Void... params) {
    try {
        Log.i(TransactionTask.class.getName(), …
Run Code Online (Sandbox Code Playgroud)

java android android-asynctask

5
推荐指数
1
解决办法
508
查看次数

比较从char []创建的字符串

我的代码比较了两个单词之间的相等性.如果字符串相等,它会打印一个值"TRUE".否则它返回false.正在使用Java"等于"功能

class k{  

    public static void main(String args[]){  
        String s1="Sach";  
        String s2=word();  
        String s3=new String("Sach");   
        System.out.println(s1.equals(s2));  
        System.out.println(s1.equals(s3));      
    } 

    public static String word() {
        char[] str=new char[100];
        str[0]='S';
        str[1]='a';
        str[2]='c';
        str[3]='h';
        String ss=new String(str);
        System.out.println(ss);
        return ss;
    }
} 
Run Code Online (Sandbox Code Playgroud)

我需要将一些选定的字母提取到数组中并将其转换为字符串.转换后,该函数返回字符串.但是比较会导致错误的值.是否有其他方法将数组转换为字符串,以便此程序提供正确的结果.

java string compare

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

如何在延迟5秒后自动点击Android中的按钮

我有一个小的Android应用程序,在5秒后自动点击按钮.我用过performClick();但这不起作用.当计时器变为零时,它就会崩溃.

这是我的代码:

protected void onCreate(Bundle savedInstanceState) {
    try {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.local);
        getActionBar().setIcon(R.drawable.menu_drop);

        buttonClick();

        Thread timer = new Thread(){
            public void run(){ 
                try{
                    sleep(5000);
                } catch (InterruptedException e){
                    e.printStackTrace();
                }finally{
                    button1.performClick();
                }
            }
        };
        timer.start();
    } catch (NotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

public void buttonClick() {
    button1 = (Button) findViewById(R.id.button);
    button1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(TestButton2.this, LocationView.class);
            startActivity(i);
        } 
    }); 
}
Run Code Online (Sandbox Code Playgroud)

java mobile android

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

进度条不可转换的类型; 无法施放错误

我在我的活动XML布局中实现了一个进度条,但是当我尝试在我的活动类中强制转换它时,我收到以下错误.

不可转换的类型; 无法投射android.view.View com.project.Progress栏

我已经研究过这个错误,但我仍然不确定如何解决它.

public class ProgressBar extends Activity{

    ProgressBar progressbar;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress_bar);

        progressbar = (ProgressBar) findViewById(R.id.progressBar);
    }
}
Run Code Online (Sandbox Code Playgroud)

activity_progress_bar.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res  /android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="91dp"
        android:minHeight="60dp"
        android:minWidth="220dp" />

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

android android-layout progress-bar

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

保留循环变量值的问题

我在这段代码中有一个错误,我已将公共类变量mCountryCode声明为String.

 for (mCountryCode : isoCountryCodes) {
     locale = new Locale("", mCountryCode);
     if(locale.getDisplayCountry().equals(mSpinner.getSelectedItem())) {
         mCountryCode = locale.getCountry();                        
         break;
     }
 }
Run Code Online (Sandbox Code Playgroud)

如果我使用,for (String mCountryCode : isoCountryCodes)那么错误将消失,但我无法维持行mCountryCode后的字符串值break;.

java android

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