Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android studio 我不知道为什么,但它在startActivity(StartIntent)上让我崩溃了;我尝试将类User的ArrayList沙化为ScenedActivity_Android Studio - Fatal编程技术网

Android studio 我不知道为什么,但它在startActivity(StartIntent)上让我崩溃了;我尝试将类User的ArrayList沙化为ScenedActivity

Android studio 我不知道为什么,但它在startActivity(StartIntent)上让我崩溃了;我尝试将类User的ArrayList沙化为ScenedActivity,android-studio,Android Studio,星体触觉(StartIntent)上的cod崩溃; 我不知道为什么我要创办安卓工作室,我试着编写我脑海中的代码 我不知道为什么,但它在startActivity(StartIntent)上让我崩溃了;我尝试将类User的ArrayList沙化为ScenedActivity ArrayList<User> users = new ArrayList<>(); User Dan = new User("dan","ali","

星体触觉(StartIntent)上的cod崩溃; 我不知道为什么我要创办安卓工作室,我试着编写我脑海中的代码 我不知道为什么,但它在startActivity(StartIntent)上让我崩溃了;我尝试将类User的ArrayList沙化为ScenedActivity

ArrayList<User> users = new ArrayList<>();
User Dan = new User("dan","ali","game12",1234);
static int cod;
final int num = 10;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    users.add(Dan);
    setContentView(R.layout.activity_main);
    final EditText Cod = findViewById(R.id.Cod);
    Button NextActivity = findViewById(R.id.NextActivity);
    NextActivity.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!isEmpty(Cod))//if the text box is empty pot 0 in cod
                cod = Integer.parseInt(Cod.getText().toString());
            else if (isEmpty(Cod))
                cod = 0;
            if (cod == num ) {// if the cod that pot in EditText = my cod(num) go on
                Intent StartIntent = new Intent(getApplicationContext(), ScenedActivity.class);
                StartIntent.putExtra("android.intent.category.LAUNCHER", "Hi");//sand to scened activity string "hi"
                StartIntent.putExtra("android.intent.category.LAUNCHER1",users);//sand to scened activity ArrayList of User
                startActivity(StartIntent);

            }
            else {
                Toast.makeText(getBaseContext(),"Error worng code",Toast.LENGTH_SHORT).show();//sand 
            }
        }
    });
}
private boolean isEmpty(EditText etText) {//check if text box is empty
    if (etText.getText().toString().trim().length() > 0)
        return false;

    return true;
}
ArrayList users=new ArrayList();
用户丹=新用户(“丹”、“阿里”、“游戏12”、1234);
静态int-cod;
最终整数=10;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
添加(Dan);
setContentView(R.layout.activity_main);
最终编辑文本Cod=findViewById(R.id.Cod);
按钮NextActivity=findviewbyd(R.id.NextActivity);
NextActivity.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
if(!isEmpty(Cod))//如果文本框是Cod中的空罐0
cod=Integer.parseInt(cod.getText().toString());
否则,如果(isEmpty(Cod))
cod=0;
如果(cod==num){//如果EditText中的锅的cod=my cod(num)继续
Intent startinent=newintent(getApplicationContext(),ScenedActivity.class);
startinent.putExtra(“android.intent.category.LAUNCHER”,“Hi”);//将沙粒添加到带香味的活动字符串“Hi”
startinent.putExtra(“android.intent.category.LAUNCHER1”,users);//指向用户的场景活动数组列表
startActivity(startinent);
}
否则{
Toast.makeText(getBaseContext(),“错误工作代码”,Toast.LENGTH_SHORT).show();//sand
}
}
});
}
私有布尔值isEmpty(EditText-ettText){//检查文本框是否为空
if(etText.getText().toString().trim().length()>0)
返回false;
返回true;
}

}

您能显示错误消息吗?我想它是这样的:(这不是全部我不能和全部错误)E/AndroidRuntime:FATAL EXCEPTION:main Process:com.example.myapplication,PID:12754 java.lang.RuntimeException:Parcel:无法封送值com.example.myapplication。User@6f3d786(谢谢。)你能显示错误消息吗?我想它是这样的:(这不是所有我不能和所有错误)E/AndroidRuntime:致命异常:主进程:com.example.myapplication,PID:12754 java.lang.RuntimeException:包裹:无法封送值com.example.myapplication。User@6f3d786(谢谢。)