Android 文本列表和可单击列表
我想问一下如何制作一个文本列表,我们可以点击每个文本,然后将所选文本编辑成文本。 我刚刚添加了截图Android 文本列表和可单击列表,android,Android,我想问一下如何制作一个文本列表,我们可以点击每个文本,然后将所选文本编辑成文本。 我刚刚添加了截图 从昨天起我就一直在找,但我找不到确切的答案。我也尝试过使用listview,但我不知道如何使用水平和流列表项 您能否根据需要制作尽可能多的按钮,然后在所有按钮的按钮单击方法中添加: Buttonwithtext_Click(object sender, EventArgs e) { editTextBox.Text = editTextBox.Text + But
从昨天起我就一直在找,但我找不到确切的答案。我也尝试过使用listview,但我不知道如何使用水平和流列表项 您能否根据需要制作尽可能多的按钮,然后在所有按钮的按钮单击方法中添加:
Buttonwithtext_Click(object sender, EventArgs e)
{
editTextBox.Text = editTextBox.Text + Buttonwithtext.text + ", ":
}
我也是android新手。但我能想到你想要的逻辑。如果你愿意,你可以试试这个
EditText
文本
编辑文本的对象
EditText
的值存储到字符串变量中EditText
中的文本 // Adding EditText and a button in a new linear layout and then adding
// the new linearLayout to the main layout
String[] valuesToBeAdded={"A","B","C","D"};
String selectedValues=null;
LinearLayout mainLayout=(LinearLayout) findViewById(R.id.mainLayout);
LinearLayout localLayout = new LinearLayout(context);
localLayout.setOrientation(LinearLayout.VERTICAL);
localLayout.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
EditText editText=new EditText(context);
editText.setText(selectedValues);
editText.setId(5000);
localLayout.addView(editText);
for(int i=0;i<valuesToBeAdded.length();i++){
Button button = new Button(context);
button.setText(R.string.scanDocument);
button.setId(i);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
EditText ed=(EditText) findViewById(5000);
selectedValues=ed.getText();
selectedValues=selectedValues +" " + this.getText();
ed.setText(selectedValues);
}
});
localLayout.addView(button);
}
mainLayout.addView(localLayout);
//在新的线性布局中添加EditText和按钮,然后添加
//主布局的新线性布局
字符串[]valuesToBeAdded={“A”、“B”、“C”、“D”};
字符串selectedValues=null;
LinearLayout mainLayout=(LinearLayout)findViewById(R.id.mainLayout);
LinearLayout localLayout=新的LinearLayout(上下文);
localLayout.setOrientation(LinearLayout.VERTICAL);
localLayout.setLayoutParams(新的LayoutParams(
LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
EditText EditText=新的EditText(上下文);
editText.setText(selectedValues);
editText.setId(5000);
localLayout.addView(editText);
对于(int i=0;i您是否仍在寻找答案?如果我的答案达到了您尝试的目的,请将其标记为答案。对不起,我刚刚在设置中激活了电子邮件通知。因此我将尽快收到您的答案。是否介意至少对我的答案投赞成票,而不是接受?谢谢。我认为这是不可能的,您能否给出一些建议android的实际实现中的示例?如何管理布局中的按钮?@Huteri抱歉,我对android的东西感到不知所措:(.哦,没关系。我很感谢你试图帮助我。我有动态数据,就像上面例子中的标记一样。所以我必须以编程方式制作按钮。我明白你的意思,但我仍然对如何获取视图并将按钮放在现有布局和特定区域感到困惑。哇,是的,这几乎可以完成任务,你能帮我一点忙吗当按钮太多时,re?Linear layout无法自动生成新行。(我在这里使用的是水平方向)除了使用Linear layout,还有其他选择吗?是的……您可以使用RelativeLayout
而不是LinearLayout
尝试在线查询它:-)是的,我刚刚找到答案,使用流布局..谢谢