应用从用户那里获取名称和分数,提交后应显示得分最高的用户的名称和分数。
显示前3个得分及其名称的逻辑是什么?
我正在尝试创建一个应用程序,供法官在任何colg事件中进行判断。
//代码
Button submit;
EditText t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_secondactivity);
/* how to add all edit text in array ? */
t1 = (EditText) findViewById(R.id.edittext1);
t2 = (EditText)findViewById(R.id.edittext2);
t3 = (EditText)findViewById(R.id.edittext);
t4 = (EditText)findViewById(R.id.edittext3);
t5 = (EditText)findViewById(R.id.edittext4);
t6 = (EditText)findViewById(R.id.edittext5);
t7 = (EditText)findViewById(R.id.edittext6);
t8 = (EditText)findViewById(R.id.edittext7);
t9 = (EditText)findViewById(R.id.edittext8);
t10 = (EditText)findViewById(R.id.edittext9);
t11 = (EditText)findViewById(R.id.edittext10);
t12 = (EditText)findViewById(R.id.edittext11);
submit = (Button) findViewById(R.id.submit);
Firebase.setAndroidContext(getApplicationContext());
}
public void click(View view)
{
String name = t1.getText().toString();
String point= t2.getText().toString();
String name2= t3.getText().toString();
String point2= t8.getText().toString();
String name3= t4.getText().toString();
String point3= t9.getText().toString();
String name4= t5.getText().toString();
String point4= t10.getText().toString();
String name5= t6.getText().toString();
String point5= t11.getText().toString();
String name6= t7.getText().toString();
String point6= t12.getText().toString(); }
如何创建EditText
个数组?
答案 0 :(得分:1)
this.props.navigation.navigate('XYZScreen'{itemID:id,fromWhere:"NOTIFICATION"})
其中ArrayList<EditText> editTextList = new ArrayList<EditText>();
for(int i = 0; i < rootLayout.getChildCount(); i++) {
if(rootLayout.getChildAt(i) instanceof EditText) {
editTextList.add( (EditText) rootLayout.getChildAt(i));
}
}
是包含所有rootLayout
的视图(例如,LinearLayout)
要添加edittext数组,您可以尝试一下。