0

请任何人都可以给我这个例子“我在这些用户中输入后有一些编辑文本将点击保存按钮然后显示一个带有第一个edittext值和第一个字符的列表视图,当点击列表视图项目然后显示那些编辑将文本值转换为新活动的不同 2 文本视图”请帮助我。

4

3 回答 3

1
public void onClick (View view) {


     Intent intent = new Intent (this,display.class);

     RelativeLayout relativeLayout = (RelativeLayout) view.getParent();

        TextView textView = (TextView) relativeLayout.findViewById(R.id.textView1);
//      TextView textView=(TextView) findViewById(R.id.textView1); for single //textview we use this
        String message = textView.getText().toString();
        intent.putExtra(EXTRA_MESSAGE,message);
        startActivity(intent);

    }

显示.java

public void onCreate(Bundle savedInstanceState) 
     {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.display);


                // Get the message from the intent
                Intent intent = getIntent();
                String message = intent.getStringExtra(Listd.EXTRA_MESSAGE);

                // Create the text view
                EditText editText = new EditText(this);
                editText.setTextSize(40);
                editText.setText(message);
                // Set the text view as the activity layout
                setContentView(editText);

}

希望你从上面的代码中理解

于 2012-08-13T08:53:55.583 回答
0

您可以将值传递给 listView 项目上的另一个 Activity 点击为:

ListView list_view = (ListView)findViewById(R.id.listvv);
        list_view.setAdapter(adapter); //set adapter here
        list_view.setOnItemClickListener(new OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView parent, View view, int position, long id)
            {
                try
                {
                    EditText edttx = (EditText)view.findViewById(R.id.txtviewtxt);
                    String edttxtxtx = edttx.getText().toString();
                    Intent i = new Intent(YouCurentActivity.this, New_Activity.class);

                    i.putExtra("txtx", edttxtxtx);
                    startActivity(i);
                }
                catch(Exception ex)
                {

                }
            }
        });

在 New_Activity.class onCreate 中:

Bundle extras = getIntent().getExtras();
String strvalue= extras.getString("txtx");
于 2012-06-27T10:51:05.450 回答
-1

在这些用户中输入后我有一些编辑文本将单击保存按钮然后显示一个列表视图,其中包含第一个带有第一个字符的 edittext 值

=> 由于您只想在 ListView 中显示一个行项目,因此ArrayAdapter最适合,否则您必须创建自定义适配器以显示 ListView 的自定义布局项。

是的,每当您单击“保存”按钮时,不要忘记在 Array/ArrayList 中添加当前条目并notifyDataSetChanged()通知适配器有关数据的更改。

当单击列表视图项时,然后将那些编辑文本值显示到新活动的不同 2 文本视图中

=> setOnItemClickListener()帮助你。

于 2012-06-27T10:53:54.650 回答