自动化停止工作

时间:2016-02-25 05:55:15

标签: java android xml android-studio

当我尝试在模拟器上运行这个简单的程序时,说自动化(项目名称)停止工作。我只是测试一个简单的ui并计划将通过蓝牙接收的数据发送到arduino,但意外地发生了这种情况。

package company.ciso.com.automation;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.SeekBar;
import android.widget.Switch;
import android.widget.TextView;

public class Automoate extends AppCompatActivity {
static TextView text1 ;
static TextView text2 ;
static TextView text3 ;
static SeekBar seek1;
static SeekBar seek2;
static  SeekBar seek3;
static Switch switch1;
static Switch switch2;
static Switch switch3;
// static int seekpos1;
// static int seekpos2;
// static int seekpos3;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_automoate);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    autofunction();


}
protected void autofunction(){
     text1 = (TextView)findViewById(R.id.textView)  ;
     text2 = (TextView)findViewById(R.id.textView2)  ;
    text3 = (TextView)findViewById(R.id.textView3)  ;
     seek1 = (SeekBar) findViewById(R.id.seekBar);
    seek2 = (SeekBar) findViewById(R.id.seekBar2);
     seek3 = (SeekBar) findViewById(R.id.seekBar3);
    switch1 = (Switch) findViewById(R.id.switch1);
    switch2 = (Switch) findViewById(R.id.switch2);
     switch3 = (Switch) findViewById(R.id.switch3);
     text1.setText(seek1.getProgress());
     text2.setText(seek2.getProgress());
     text3.setText(seek3.getProgress());





}
}

这是错误LOg.also我将不胜感激如何在错误代码中查找问题。

  02-25 11:35:24.126 3818-3818/? I/art: Not late-enabling -Xcheck:jni    (already    on)
 02-25 11:35:24.193 3818-3818/? W/System: ClassLoader referenced unknown     path: /data/app/company.ciso.com.automation-2/lib/x86
   02-25 11:35:24.199 3818-3824/? E/art: Failed sending reply to debugger: Broken pipe
 02-25 11:35:24.199 3818-3824/? I/art: Debugger is no longer active
   02-25 11:35:24.254 3818-3818/? W/ResourceType: No package identifier when           getting value for resource number 0x00000000
      02-25 11:35:24.257 3818-3818/? D/AndroidRuntime: Shutting down VM
       02-25 11:35:24.257 3818-3818/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             Process: company.ciso.com.automation, PID: 3818
                                             java.lang.RuntimeException: Unable to start activity ComponentInfo{company.ciso.com.automation/company.ciso.com.automation.Automoate}: android.content.res.Resources$NotFoundException: String resource ID #0x0
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                 at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                 at android.os.Looper.loop(Looper.java:148)
                                                 at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                              Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
                                                 at android.content.res.Resources.getText(Resources.java:312)
                                                 at android.widget.TextView.setText(TextView.java:4417)
                                                 at company.ciso.com.automation.Automoate.autofunction(Automoate.java:46)
                                                 at company.ciso.com.automation.Automoate.onCreate(Automoate.java:32)
                                                 at android.app.Activity.performCreate(Activity.java:6237)
                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                 at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                 at android.os.Looper.loop(Looper.java:148) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                 at java.lang.reflect.Method.invoke(Native Method) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

这是我的Automoate.xml

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_automoate" />

1 个答案:

答案 0 :(得分:0)

错误是seek1.getProgress()返回类型是整数您不能直接将整数传递给textview。要传递 integer ,您必须使用String.xml文件 解决方案1 ​​text1.setText(seek1.getProgress()+"");
解决方案2 :如果您要定期更新进度到文本视图,则意味着使用SeekBar.OnSeekBarChangeListener()