//这是我今天早些时候发布的帖子的更新。
我想在 Parse.com 的 Anywall 应用程序的“发布”对话框中填充一些字段。使用下面的代码我只能填充一个字段。有人看到我做错了什么吗?我认为问题可能与 alert.setView
有关。
// Create the builder where the new post is entered
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
alert.setTitle("Create a Bicyclist Count Post");
final EditText input = new EditText(MainActivity.this);
final EditText inputNotes = new EditText(MainActivity.this);
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
inputNotes.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
alert.setView(input);
alert.setView(inputNotes);
// Handle the dialog input
alert.setPositiveButton("Post", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Create a post.
AnywallPost post = new AnywallPost();
// Set the location to the current user's location
post.setLocation(myPoint);
post.setText(input.getText().toString());
post.setNotes(inputNotes.getText().toString());
//更新结束
我希望允许用户在 Parse.com 示例的发布屏幕中填充其他字段 Anywall应用。我通过我的 Parse.com 帐户在表中添加了新列 bicyclistCount:
我无法将其显示在“发布”屏幕中。用户在下图中输入文本的区域填充文本列。有人能够在 Anywall 应用程序中向其帖子添加其他字段吗?谢谢
最佳答案
这是一个简单的技术。尝试将所有edittext
添加到垂直
方向的线性布局
中,然后将此布局( View )设置为警报对话框
例如:
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle("Create a Bicyclist Count Post");
LinearLayout layout = new LinearLayout(context);
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setLayoutParams(params);
final EditText input = new EditText(context);
final EditText inputNotes = new EditText(context);
//do your remaining stuff with input and inputNotes
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
inputNotes.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
layout.addView(input);
layout.addView(inputNotes);
alert.setView(layout);
alert.show();
关于java - 在 Parse.com 应用程序中向 Post 添加新字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26005657/