0

The screen shot of my problem is provided in this link:

https://goo.gl/photos/24BTZMX1DxLXnm5J9

I am using two separate activities, for example activity A and activity B. In activity A, I have incorporated an edit text field. If the user enters some characters within double quotations, I have to display only the characters that are mentioned inside the double quotations.

For example, if the user input in the edittext is like

Value = "Welcome to the restaurant"

It has to display Welcome to the restaurant in the activity B, by neglecting Value=

Please help me on this. Thanks in advance Save Our Souls.

2 Answers2

1

Try this (Keeping in mind your sentense I want to display the things inside the double quotes alone.)

    String example="Value = \"Welcome to the restaurant\""; //replace with EditText value

    int firstQuoteIndex=example.indexOf("\"")+1;
    int lastQuoteIndex=example.lastIndexOf("\"");

    String result=example.substring(firstQuoteIndex, lastQuoteIndex);
Bharatesh
  • 8,375
  • 3
  • 34
  • 61
0
  1. in activity A

    String usertext= edittext.getText().toString();
    

2.

Intent i =new Intent(A.this,B.class);
i.putExtra("uservalue",usertext);
startActivity(i);

3. In B activity

String valueretrn=getIntent().getExtra().getString("uservalue");
textview.setText(valueretrn);
raj
  • 2,049
  • 12
  • 22