0

Please can anyone give me the example for this "I have some edit text after doing entry in these user will click on save button then show a listview with first of edittext value with first character and when click on list view item then show those those edit text value into different-2 textview of new activity" plz help me in this.

kapil
  • 1
  • 2

3 Answers3

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);

    }

displaly.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);

}

hope u understand from above code

Umesh Panchani
  • 420
  • 3
  • 13
0

You can pass value to another Activity on listView item Click as:

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)
                {

                }
            }
        });

In New_Activity.class onCreate:

Bundle extras = getIntent().getExtras();
String strvalue= extras.getString("txtx");
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
-1

I have some edit text after doing entry in these user will click on save button then show a listview with first of edittext value with first character

=> As you want to display only one line item in your ListView, ArrayAdapter suits best otherwise you have to create custom adapter for displaying custom layout item for your ListView.

And yes, whenever you click on Save button, dont forget to add the current entry in Array/ArrayList and notifyDataSetChanged() to notify adapter about changes in data.

when click on list view item then show those those edit text value into different-2 textview of new activity

=> setOnItemClickListener() help you out.

Community
  • 1
  • 1
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295