查看后视点指针 1/0
我有以下代码,没有编译错误,只是导致无限循环...我不明白问题出在哪里。
单击 Button 时,我想使用在编辑文本中输入的值创建一个对象,并将它们传递给另一个活动。但相反,我得到了一个循环。
每个微调器都使用来自资源/字符串的字符串数组进行填充。我在这里获得值时遇到了一些困难,因为在微调器上,当选择“Profesor”时,我想被禁用,而当选择“学生”时,我想被禁用,但这也不起作用。根据该选项,将选择下一个活动,该活动将在单击按钮后打开。spTipUtilizator
spGrupa
spdept
另外,为什么在我的日历中设置默认日期不起作用?我尝试了这里发现的多种方法,但没有一个对我有用。我的Android Studio没有显示,我更喜欢,只有日历。DatePicker
public class SignInActivity extends Activity {
private Button bSignup;
private EditText etNume, etPrenume, etUsername, etPassword, etConfirmPass, etEmail;
private RadioButton rbMasc, rbFem;
private Spinner spTipUtilizator, spgrupa, spdept;
private ProgressBar progBar;
private Calendar calendar;
private int year, month, day, currentYear, defday, defmonth, defyear;
private List<String> tipUtilizatorList, grupaList;
private ArrayAdapter<String> spinnerArrayAdapterTipU;
private String nume,prenume,username,password,password2,email,masc,fem,sex,tipUser,dept,DataN;
private int grupa;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
calendar=Calendar.getInstance();
calendar.set(1990,12,12);
bSignup = findViewById(R.id.buttonSignin);
etNume=findViewById(R.id.et_nume);
etPrenume=findViewById(R.id.et_prenume);
etUsername=findViewById(R.id.et_username);
etPassword=findViewById(R.id.et_password);
etConfirmPass = findViewById(R.id.et_confirmpassword);
etEmail=findViewById(R.id.et_email);
rbMasc=findViewById(R.id.radioButtonMasc);
rbFem=findViewById(R.id.radioButtonFem);
spTipUtilizator=findViewById(R.id.spinnerTipUtilizator);
spgrupa=findViewById(R.id.spinnerGrupa);
spdept=findViewById(R.id.spinnerDepartament);
progBar = findViewById(R.id.progressBar);
tipUtilizatorList=new ArrayList<>(Arrays.asList(getResources().getStringArray((R.array.tipUtilizator))));
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,tipUtilizatorList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spTipUtilizator.setAdapter(adapter);
grupaList = new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.grupa)));
bSignup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
nume = etNume.getText().toString().trim();
prenume = etPrenume.getText().toString().trim();
username = etUsername.getText().toString().trim();
password = etPassword.getText().toString().trim();
password2 = etConfirmPass.getText().toString().trim();
email = etEmail.getText().toString().trim();
masc = rbMasc.getText().toString().trim();
fem = rbFem.getText().toString().trim();
sex=fem;
tipUser = spTipUtilizator.getSelectedItem().toString().trim();
grupa = Integer.parseInt(spgrupa.getSelectedItem().toString().trim());
dept = spdept.getSelectedItem().toString().trim();
DataN = day+"/"+month+"/"+year;
progBar.setVisibility(View.VISIBLE);
if(rbFem.isChecked()) {
sex=fem;
}
else if(rbMasc.isChecked()) {
sex=masc;
}
spTipUtilizator.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String Text = parent.getSelectedItem().toString();
if(Text.equals("Profesor")) {
spgrupa.getSelectedView().setEnabled(false);
spdept.getSelectedView().setEnabled(true);
Intent intent = new Intent(getApplicationContext(),StartProfesorActivity.class);
Profesor prof = new Profesor(nume,prenume,username,password,email,sex,dept,DataN);
intent.putExtra("profesor",prof);
startActivity(intent);
return;
}
else if(Text.equals("Student")) {
spgrupa.getSelectedView().setEnabled(true);
spdept.getSelectedView().setEnabled(false);
Intent intent = new Intent(getApplicationContext(),StartStudentActivity.class);
Student stud = new Student(nume,prenume,username,password,email,sex,grupa, DataN);
intent.putExtra("student",stud);
startActivity(intent);
return;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
});
}
}
日志:
D/AbsListView: in onLayout changed
D/ViewRootImpl@cab402e[PopupWindow:ad4e773]: MSG_WINDOW_FOCUS_CHANGED 1
V/InputMethodManager: Not IME target window, ignoring
D/ViewRootImpl@cab402e[PopupWindow:ad4e773]: MSG_RESIZED_REPORT: frame=Rect(266, 72 - 422, 1047) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
D/ViewRootImpl@27d7010[SignInActivity]: MSG_WINDOW_FOCUS_CHANGED 0
D/ViewRootImpl@cab402e[PopupWindow:ad4e773]: ViewPostIme pointer 0
D/ViewRootImpl@cab402e[PopupWindow:ad4e773]: ViewPostIme pointer 1
D/AbsListView: onTouchUp() mTouchMode : 0
D/ViewRootImpl@cab402e[PopupWindow:ad4e773]: Relayout returned: old=[266,72][422,1047] new=[266,72][422,1047] result=0x1 surface={valid=true 481098420224} changed=false
D/ViewRootImpl@27d7010[SignInActivity]: MSG_WINDOW_FOCUS_CHANGED 1
D/ViewRootImpl@cab402e[PopupWindow:ad4e773]: MSG_WINDOW_FOCUS_CHANGED 0
I/zygote64: Compiler allocated 4MB to compile void android.view.View.<init>(android.content.Context, android.util.AttributeSet, int, int)
I/OpenGLRenderer: prepareTree mLayerUpdateQueue is not empty, size = 1
name = PopupWindow$PopupBackgroundView, size (156, 975)
D/OpenGLRenderer: eglDestroySurface = 0x6ff4459d80
endAllActiveAnimators on 0x6ff591ec00 (DropDownListView) with handle 0x7003b6eb00
D/ViewRootImpl@cab402e[PopupWindow:ad4e773]: dispatchDetachedFromWindow
D/InputEventReceiver: channel '468478f PopupWindow:ad4e773 (client)' ~ Disposing input event receiver.
channel '468478f PopupWindow:ad4e773 (client)' ~NativeInputEventReceiver.
D/ViewRootImpl@27d7010[SignInActivity]: ViewPostIme pointer 0
D/ViewRootImpl@27d7010[SignInActivity]: ViewPostIme pointer 1
D/ViewRootImpl@27d7010[SignInActivity]: ViewPostIme pointer 0
D/ViewRootImpl@27d7010[SignInActivity]: ViewPostIme pointer 1
D/ViewRootImpl@27d7010[SignInActivity]: ViewPostIme pointer 0
D/ViewRootImpl@27d7010[SignInActivity]: ViewPostIme pointer 1
D/ViewRootImpl@27d7010[SignInActivity]: ViewPostIme pointer 0
D/ViewRootImpl@27d7010[SignInActivity]: ViewPostIme pointer 1
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@54a19af nm : com.example.ancaa.proiectandroidquiz ic=com.android.internal.widget.EditableInputConnection@ba71bc
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
W/IInputConnectionWrapper: getCursorCapsMode on inactive InputConnection
W/IInputConnectionWrapper: getCursorCapsMode on inactive InputConnection
W/IInputConnectionWrapper: getSelectedText on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
D/OpenGLRenderer: eglDestroySurface = 0x7003ab7400
D/ViewRootImpl@27d7010[SignInActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x5 surface={valid=false 0} changed=true
D/ViewRootImpl@27d7010[SignInActivity]: MSG_WINDOW_FOCUS_CHANGED 0
D/ViewRootImpl@27d7010[SignInActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=false 0} changed=false
Application terminated.