如何查找edittext
附近TextView
( “输入linedata数量”)? 这是我code..Is有可能做这里面LinearLayout
public class Ybus_Activity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ybus);
final LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
final LinearLayout main = (LinearLayout)findViewById(R.id.android_main_layout);
TextView getData=new TextView(this);
getData.setText("Enter the number of LineData : ");
getData.setId(5);
getData.setLayoutParams(params);
main.addView(getData);
final EditText edText = new EditText(this);
edText.setId(3);
edText.setLayoutParams(params);
edText .setWidth(100);
edText .setImeOptions(EditorInfo.IME_ACTION_NEXT);
edText .setInputType(InputType.TYPE_CLASS_NUMBER);
edText .setKeyListener(DigitsKeyListener.getInstance());
edText .setMaxLines(1);
main.addView(edText);
Button bt = new Button(this);
bt.setText("Click to enter Linedata");
bt.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
main.addView(bt);
final TextView text = new TextView(this);
bt.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
String ed=edText.getText().toString();
int i = 0;
try{
i =Integer.parseInt(ed);
//setting value here
text.setText(i+"");
//or you can do like this
//text.setText(String.valueOf(i));
}catch(NumberFormatException ex){
text.setText("Value at TextView is not a valid integer");
}
}
});
main.addView(text);
}
}
@Raghunandan如何兄弟??我是新来的Android .. – gkn06
对不起,我误解了这个问题。你想以编程方式移动textview旁边的视图? – Raghunandan
如何将edittext移动到文本视图 – gkn06