我想跳进一个用户提供数字输入的课程。 我试过这个:
EditText eTinput;
int n;
n=eTinput.getText().toString;
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
Class ourClass =Class.forName("com.dvdroid.kannadavachanagalu.Shareb",+n);
Intent ourintent = new Intent(BasavaSelect.this, ourClass);
startActivity(ourintent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
});
但我收到一些错误,因为'将输入n更改为可编辑'和'删除参数以匹配forname'
有人可以帮忙怎么做吗?
答案 0 :(得分:0)
EditText eTinput;
eTinput = (EditText)findViewById(R.id.yourEdittextIdFromXml);
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
if(n==urvaluetocheck)
{
Intent ourintent = new Intent(BasavaSelect.this, ourClass);
startActivity(ourintent);
}
else if(n==urvaluetocheck)
{
Intent ourintent = new Intent(BasavaSelect.this, classuwant);
startActivity(ourintent);
}
..........
else
{
Intent ourintent = new Intent(BasavaSelect.this, defaultclass);
startActivity(ourintent);
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
});
答案 1 :(得分:0)
试试如下:
EditText eTinput;
int n;
n=eTinput.getText().toString;
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
Class ourClass=Class.forName("com.dvdroid.kannadavachanagalu.Shareb");//Change this line
Intent ourintent = new Intent(BasavaSelect.this, ourClass);
ourintent.putExtra("Value", n);
startActivity(ourintent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
});
答案 2 :(得分:0)
使用它:
eTinput = (EditText)findViewById(R.id.yourEdittextIdFromXml);