ANDROID: Get next item from listview to editText after 1st item is saved
What I have: (1st Functionality)
I have a listview activity populated with items from JSON url. I have another activity where I get the listItem to editText field and then click "save", which saves the value to dB.
What I additionally want: (2nd Functionality)
When I click save, rather than going back to listview and select next listItem, I want the editText to fill the new listItem for me. But I am making errors in every step.
Below is the code that I have for 1st Functionality. I know it is just few lines to achieve the 2nd functionality but struggling with that.
The problem here is I cannot call the list String variable from one
activity to another and assign position or a counter to it. Suggest me
what to change here.
MainActivity.java (Class containing ListView populated with item from json url)
package com.example.app.listview;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
ListView listView;
ArrayList<String> tutorialList = new ArrayList<String>();
private final static String URL = "-----json------url----file";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new FetchDataTask().execute(URL);
}
private class FetchDataTask extends AsyncTask<String, Void, String>{
@Override
protected String doInBackground(String... params) {
InputStream inputStream = null;
String result= null;
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(params[0]);
try {
HttpResponse response = client.execute(httpGet);
inputStream = response.getEntity().getContent();
// convert inputstream to string
if(inputStream != null){
result = convertInputStreamToString(inputStream);
Log.i("App", "Data received:" +result);
}
else
result = "Failed to fetch data";
return result;
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String dataFetched) {
//parse the JSON data and then display
parseJSON(dataFetched);
}
private String convertInputStreamToString(InputStream inputStream) throws IOException{
BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
String line = "";
String result = "";
while((line = bufferedReader.readLine()) != null)
result += line;
inputStream.close();
return result;
}
private void parseJSON(String data){
try{
JSONArray jsonMainNode = new JSONArray(data);
int jsonArrLength = jsonMainNode.length();
for(int i=0; i < jsonArrLength; i++) {
JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
String postTitle = jsonChildNode.getString("codeid");
tutorialList.add(postTitle);
}
// Get ListView object from xml
listView = (ListView) findViewById(R.id.list);
// Define a new Adapter
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, tutorialList);
// Assign adapter to ListView
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent(MainActivity.this, AddFlowerInfo.class);
intent.putExtra("Code", listView.getItemAtPosition(i).toString());
startActivity(intent);
}
});
}catch(Exception e){
Log.i("App", "Error parsing data" +e.getMessage());
}
}
}
}
editText.java (class containing editText field and save to dB)
package com.example.app.listview;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.util.Log;
import android.view.View;
public class AddFlowerInfo extends AppCompatActivity {
EditText editText; //non editable codeid <<----<<----<<----<<--<<---<<1
private static final String TAG = "AddFlowerInfo";
Button savedata;
String noneditcode;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_flower_info);
editText = (EditText) findViewById(R.id.codeid);
savedata = (Button) findViewById(R.id.saveflowerinfo);
final String Codeholder = getIntent().getStringExtra("Code");
editText.setText(Codeholder);
}
public void dataflowerinfo(View view){
noneditcode = editText.getText().toString();
String method = "FlowerInfo";
BackgroundTask2 backgroundTask2 = new BackgroundTask2(this);
backgroundTask2.execute(method, noneditcode);
finish();
}
UPDATE AddFlowerInfo.java (OnCreate) and (OnClick)
public class AddFlowerInfo extends AppCompatActivity {
EditText editText; //non editable codeid <<----<<----<<----<<--<<---<<1
private static final String TAG = "AddFlowerInfo";
Button savedata;
int i=0;
String noneditcode;
int pos;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_flower_info);
editText = (EditText) findViewById(R.id.codeid);
savedata = (Button) findViewById(R.id.saveflowerinfo);
Intent i =getIntent();
final ArrayList<String> list = i.getStringArrayListExtra("key");
pos = i.getIntExtra("position", 0);
// final String Codeholder = getIntent().getStringExtra("Code");
editText.setText(list.get(pos));
savedata.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(AddFlowerInfo.this, AddFlowerInfo.class);
startActivity(intent);
++pos;
if(pos<=list.size()-1)
list.get(pos);
}
});
java
|
show 16 more comments
What I have: (1st Functionality)
I have a listview activity populated with items from JSON url. I have another activity where I get the listItem to editText field and then click "save", which saves the value to dB.
What I additionally want: (2nd Functionality)
When I click save, rather than going back to listview and select next listItem, I want the editText to fill the new listItem for me. But I am making errors in every step.
Below is the code that I have for 1st Functionality. I know it is just few lines to achieve the 2nd functionality but struggling with that.
The problem here is I cannot call the list String variable from one
activity to another and assign position or a counter to it. Suggest me
what to change here.
MainActivity.java (Class containing ListView populated with item from json url)
package com.example.app.listview;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
ListView listView;
ArrayList<String> tutorialList = new ArrayList<String>();
private final static String URL = "-----json------url----file";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new FetchDataTask().execute(URL);
}
private class FetchDataTask extends AsyncTask<String, Void, String>{
@Override
protected String doInBackground(String... params) {
InputStream inputStream = null;
String result= null;
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(params[0]);
try {
HttpResponse response = client.execute(httpGet);
inputStream = response.getEntity().getContent();
// convert inputstream to string
if(inputStream != null){
result = convertInputStreamToString(inputStream);
Log.i("App", "Data received:" +result);
}
else
result = "Failed to fetch data";
return result;
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String dataFetched) {
//parse the JSON data and then display
parseJSON(dataFetched);
}
private String convertInputStreamToString(InputStream inputStream) throws IOException{
BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
String line = "";
String result = "";
while((line = bufferedReader.readLine()) != null)
result += line;
inputStream.close();
return result;
}
private void parseJSON(String data){
try{
JSONArray jsonMainNode = new JSONArray(data);
int jsonArrLength = jsonMainNode.length();
for(int i=0; i < jsonArrLength; i++) {
JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
String postTitle = jsonChildNode.getString("codeid");
tutorialList.add(postTitle);
}
// Get ListView object from xml
listView = (ListView) findViewById(R.id.list);
// Define a new Adapter
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, tutorialList);
// Assign adapter to ListView
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent(MainActivity.this, AddFlowerInfo.class);
intent.putExtra("Code", listView.getItemAtPosition(i).toString());
startActivity(intent);
}
});
}catch(Exception e){
Log.i("App", "Error parsing data" +e.getMessage());
}
}
}
}
editText.java (class containing editText field and save to dB)
package com.example.app.listview;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.util.Log;
import android.view.View;
public class AddFlowerInfo extends AppCompatActivity {
EditText editText; //non editable codeid <<----<<----<<----<<--<<---<<1
private static final String TAG = "AddFlowerInfo";
Button savedata;
String noneditcode;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_flower_info);
editText = (EditText) findViewById(R.id.codeid);
savedata = (Button) findViewById(R.id.saveflowerinfo);
final String Codeholder = getIntent().getStringExtra("Code");
editText.setText(Codeholder);
}
public void dataflowerinfo(View view){
noneditcode = editText.getText().toString();
String method = "FlowerInfo";
BackgroundTask2 backgroundTask2 = new BackgroundTask2(this);
backgroundTask2.execute(method, noneditcode);
finish();
}
UPDATE AddFlowerInfo.java (OnCreate) and (OnClick)
public class AddFlowerInfo extends AppCompatActivity {
EditText editText; //non editable codeid <<----<<----<<----<<--<<---<<1
private static final String TAG = "AddFlowerInfo";
Button savedata;
int i=0;
String noneditcode;
int pos;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_flower_info);
editText = (EditText) findViewById(R.id.codeid);
savedata = (Button) findViewById(R.id.saveflowerinfo);
Intent i =getIntent();
final ArrayList<String> list = i.getStringArrayListExtra("key");
pos = i.getIntExtra("position", 0);
// final String Codeholder = getIntent().getStringExtra("Code");
editText.setText(list.get(pos));
savedata.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(AddFlowerInfo.this, AddFlowerInfo.class);
startActivity(intent);
++pos;
if(pos<=list.size()-1)
list.get(pos);
}
});
java
so are passing one string at a time to AddFlowerInfo activity.right?
– Jins Lukose
Nov 16 '18 at 5:00
yes @JinsLukose
– Arvind
Nov 16 '18 at 5:01
so you have to save all data to string array and pass it to AddFlowerInfo activity
– Jins Lukose
Nov 16 '18 at 5:03
Yes @JinsLukose , but I am not able to figure it out how to do it?
– Arvind
Nov 16 '18 at 5:04
Can you write it for me, Because cannot understand that part
– Arvind
Nov 16 '18 at 5:05
|
show 16 more comments
What I have: (1st Functionality)
I have a listview activity populated with items from JSON url. I have another activity where I get the listItem to editText field and then click "save", which saves the value to dB.
What I additionally want: (2nd Functionality)
When I click save, rather than going back to listview and select next listItem, I want the editText to fill the new listItem for me. But I am making errors in every step.
Below is the code that I have for 1st Functionality. I know it is just few lines to achieve the 2nd functionality but struggling with that.
The problem here is I cannot call the list String variable from one
activity to another and assign position or a counter to it. Suggest me
what to change here.
MainActivity.java (Class containing ListView populated with item from json url)
package com.example.app.listview;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
ListView listView;
ArrayList<String> tutorialList = new ArrayList<String>();
private final static String URL = "-----json------url----file";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new FetchDataTask().execute(URL);
}
private class FetchDataTask extends AsyncTask<String, Void, String>{
@Override
protected String doInBackground(String... params) {
InputStream inputStream = null;
String result= null;
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(params[0]);
try {
HttpResponse response = client.execute(httpGet);
inputStream = response.getEntity().getContent();
// convert inputstream to string
if(inputStream != null){
result = convertInputStreamToString(inputStream);
Log.i("App", "Data received:" +result);
}
else
result = "Failed to fetch data";
return result;
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String dataFetched) {
//parse the JSON data and then display
parseJSON(dataFetched);
}
private String convertInputStreamToString(InputStream inputStream) throws IOException{
BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
String line = "";
String result = "";
while((line = bufferedReader.readLine()) != null)
result += line;
inputStream.close();
return result;
}
private void parseJSON(String data){
try{
JSONArray jsonMainNode = new JSONArray(data);
int jsonArrLength = jsonMainNode.length();
for(int i=0; i < jsonArrLength; i++) {
JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
String postTitle = jsonChildNode.getString("codeid");
tutorialList.add(postTitle);
}
// Get ListView object from xml
listView = (ListView) findViewById(R.id.list);
// Define a new Adapter
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, tutorialList);
// Assign adapter to ListView
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent(MainActivity.this, AddFlowerInfo.class);
intent.putExtra("Code", listView.getItemAtPosition(i).toString());
startActivity(intent);
}
});
}catch(Exception e){
Log.i("App", "Error parsing data" +e.getMessage());
}
}
}
}
editText.java (class containing editText field and save to dB)
package com.example.app.listview;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.util.Log;
import android.view.View;
public class AddFlowerInfo extends AppCompatActivity {
EditText editText; //non editable codeid <<----<<----<<----<<--<<---<<1
private static final String TAG = "AddFlowerInfo";
Button savedata;
String noneditcode;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_flower_info);
editText = (EditText) findViewById(R.id.codeid);
savedata = (Button) findViewById(R.id.saveflowerinfo);
final String Codeholder = getIntent().getStringExtra("Code");
editText.setText(Codeholder);
}
public void dataflowerinfo(View view){
noneditcode = editText.getText().toString();
String method = "FlowerInfo";
BackgroundTask2 backgroundTask2 = new BackgroundTask2(this);
backgroundTask2.execute(method, noneditcode);
finish();
}
UPDATE AddFlowerInfo.java (OnCreate) and (OnClick)
public class AddFlowerInfo extends AppCompatActivity {
EditText editText; //non editable codeid <<----<<----<<----<<--<<---<<1
private static final String TAG = "AddFlowerInfo";
Button savedata;
int i=0;
String noneditcode;
int pos;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_flower_info);
editText = (EditText) findViewById(R.id.codeid);
savedata = (Button) findViewById(R.id.saveflowerinfo);
Intent i =getIntent();
final ArrayList<String> list = i.getStringArrayListExtra("key");
pos = i.getIntExtra("position", 0);
// final String Codeholder = getIntent().getStringExtra("Code");
editText.setText(list.get(pos));
savedata.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(AddFlowerInfo.this, AddFlowerInfo.class);
startActivity(intent);
++pos;
if(pos<=list.size()-1)
list.get(pos);
}
});
java
What I have: (1st Functionality)
I have a listview activity populated with items from JSON url. I have another activity where I get the listItem to editText field and then click "save", which saves the value to dB.
What I additionally want: (2nd Functionality)
When I click save, rather than going back to listview and select next listItem, I want the editText to fill the new listItem for me. But I am making errors in every step.
Below is the code that I have for 1st Functionality. I know it is just few lines to achieve the 2nd functionality but struggling with that.
The problem here is I cannot call the list String variable from one
activity to another and assign position or a counter to it. Suggest me
what to change here.
MainActivity.java (Class containing ListView populated with item from json url)
package com.example.app.listview;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
ListView listView;
ArrayList<String> tutorialList = new ArrayList<String>();
private final static String URL = "-----json------url----file";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new FetchDataTask().execute(URL);
}
private class FetchDataTask extends AsyncTask<String, Void, String>{
@Override
protected String doInBackground(String... params) {
InputStream inputStream = null;
String result= null;
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(params[0]);
try {
HttpResponse response = client.execute(httpGet);
inputStream = response.getEntity().getContent();
// convert inputstream to string
if(inputStream != null){
result = convertInputStreamToString(inputStream);
Log.i("App", "Data received:" +result);
}
else
result = "Failed to fetch data";
return result;
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String dataFetched) {
//parse the JSON data and then display
parseJSON(dataFetched);
}
private String convertInputStreamToString(InputStream inputStream) throws IOException{
BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
String line = "";
String result = "";
while((line = bufferedReader.readLine()) != null)
result += line;
inputStream.close();
return result;
}
private void parseJSON(String data){
try{
JSONArray jsonMainNode = new JSONArray(data);
int jsonArrLength = jsonMainNode.length();
for(int i=0; i < jsonArrLength; i++) {
JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
String postTitle = jsonChildNode.getString("codeid");
tutorialList.add(postTitle);
}
// Get ListView object from xml
listView = (ListView) findViewById(R.id.list);
// Define a new Adapter
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, tutorialList);
// Assign adapter to ListView
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent(MainActivity.this, AddFlowerInfo.class);
intent.putExtra("Code", listView.getItemAtPosition(i).toString());
startActivity(intent);
}
});
}catch(Exception e){
Log.i("App", "Error parsing data" +e.getMessage());
}
}
}
}
editText.java (class containing editText field and save to dB)
package com.example.app.listview;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.util.Log;
import android.view.View;
public class AddFlowerInfo extends AppCompatActivity {
EditText editText; //non editable codeid <<----<<----<<----<<--<<---<<1
private static final String TAG = "AddFlowerInfo";
Button savedata;
String noneditcode;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_flower_info);
editText = (EditText) findViewById(R.id.codeid);
savedata = (Button) findViewById(R.id.saveflowerinfo);
final String Codeholder = getIntent().getStringExtra("Code");
editText.setText(Codeholder);
}
public void dataflowerinfo(View view){
noneditcode = editText.getText().toString();
String method = "FlowerInfo";
BackgroundTask2 backgroundTask2 = new BackgroundTask2(this);
backgroundTask2.execute(method, noneditcode);
finish();
}
UPDATE AddFlowerInfo.java (OnCreate) and (OnClick)
public class AddFlowerInfo extends AppCompatActivity {
EditText editText; //non editable codeid <<----<<----<<----<<--<<---<<1
private static final String TAG = "AddFlowerInfo";
Button savedata;
int i=0;
String noneditcode;
int pos;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_flower_info);
editText = (EditText) findViewById(R.id.codeid);
savedata = (Button) findViewById(R.id.saveflowerinfo);
Intent i =getIntent();
final ArrayList<String> list = i.getStringArrayListExtra("key");
pos = i.getIntExtra("position", 0);
// final String Codeholder = getIntent().getStringExtra("Code");
editText.setText(list.get(pos));
savedata.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(AddFlowerInfo.this, AddFlowerInfo.class);
startActivity(intent);
++pos;
if(pos<=list.size()-1)
list.get(pos);
}
});
java
java
edited Nov 16 '18 at 7:56
Arvind
asked Nov 16 '18 at 4:51
ArvindArvind
46
46
so are passing one string at a time to AddFlowerInfo activity.right?
– Jins Lukose
Nov 16 '18 at 5:00
yes @JinsLukose
– Arvind
Nov 16 '18 at 5:01
so you have to save all data to string array and pass it to AddFlowerInfo activity
– Jins Lukose
Nov 16 '18 at 5:03
Yes @JinsLukose , but I am not able to figure it out how to do it?
– Arvind
Nov 16 '18 at 5:04
Can you write it for me, Because cannot understand that part
– Arvind
Nov 16 '18 at 5:05
|
show 16 more comments
so are passing one string at a time to AddFlowerInfo activity.right?
– Jins Lukose
Nov 16 '18 at 5:00
yes @JinsLukose
– Arvind
Nov 16 '18 at 5:01
so you have to save all data to string array and pass it to AddFlowerInfo activity
– Jins Lukose
Nov 16 '18 at 5:03
Yes @JinsLukose , but I am not able to figure it out how to do it?
– Arvind
Nov 16 '18 at 5:04
Can you write it for me, Because cannot understand that part
– Arvind
Nov 16 '18 at 5:05
so are passing one string at a time to AddFlowerInfo activity.right?
– Jins Lukose
Nov 16 '18 at 5:00
so are passing one string at a time to AddFlowerInfo activity.right?
– Jins Lukose
Nov 16 '18 at 5:00
yes @JinsLukose
– Arvind
Nov 16 '18 at 5:01
yes @JinsLukose
– Arvind
Nov 16 '18 at 5:01
so you have to save all data to string array and pass it to AddFlowerInfo activity
– Jins Lukose
Nov 16 '18 at 5:03
so you have to save all data to string array and pass it to AddFlowerInfo activity
– Jins Lukose
Nov 16 '18 at 5:03
Yes @JinsLukose , but I am not able to figure it out how to do it?
– Arvind
Nov 16 '18 at 5:04
Yes @JinsLukose , but I am not able to figure it out how to do it?
– Arvind
Nov 16 '18 at 5:04
Can you write it for me, Because cannot understand that part
– Arvind
Nov 16 '18 at 5:05
Can you write it for me, Because cannot understand that part
– Arvind
Nov 16 '18 at 5:05
|
show 16 more comments
2 Answers
2
active
oldest
votes
Pass your data from activity like this
ArrayList<String> tutorialList = new ArrayList<String>();
Intent intent = new Intent(ActivityName.this, Second.class);
intent.putStringArrayListExtra("key", tutorialList);
startActivity(intent);
To retrive at AddFlowerInfo
Intent i = getIntent();
ArrayList<String> list = i.getStringArrayListExtra("key");
Then as you are retrieving data from list using position ,each time after saving call data at next position
1
One concern I see with this approach is that when the user returns to the previous activity it will have old/stale data, not the one that's been edited.
– Kaustuv
Nov 16 '18 at 5:19
@Kaustuv that's correct but that can be handled if he is not calling the Json data once again rather get the data from database
– Jins Lukose
Nov 16 '18 at 5:26
@JinsLukose if I do this, in AddFlowerInfo, It is showing error on lineeditText.setText(list). It is sayingcast parameter to 'java.lang.CharSequence', Then after I did, the app is showing an exception likejava.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app.listview/com.example.app.listview.AddFlowerInfo}: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.CharSequence
– Arvind
Nov 16 '18 at 6:23
@JinsLukose can you help me out?
– Arvind
Nov 16 '18 at 8:12
the below answer is actually correct. anyway let me check
– Jins Lukose
Nov 16 '18 at 8:39
add a comment |
You need to send complete array to AddFlowerInfo with the position, so change your onItemClick code:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent(MainActivity.this, AddFlowerInfo.class);
intent.putExtra("position", i);
intent.putStringArrayListExtra("array",tutorialList);
startActivity(intent);
}
});
Now in AddFlowerInfo:
Intent i = getIntent();
ArrayList<String> tutorialList = i.getStringArrayListExtra("array");
int pos=i.getIntExtra("position",0);
Use this position to get item from tutorialList.
To update data when user gets back to previous activity, place this code:
new FetchDataTask().execute(URL);
into onResume method.
Update
After saving first item to edit second item use:
++pos;
if(pos<=tutorialList.size()-1)
editText.setText(tutorialList.get(pos));
else
{
// you are after last item do whatever you want
}
Instead of fetching everytime in onResume, won't it be better to start AddFlowerInfo activity for result, then onActivityResult fetch data if result=OK. This will prevent unnecessary fetching of data, say when coming from screen unlock.
– Kaustuv
Nov 16 '18 at 5:43
It is showing me error on lineeditText.setText(list). Here edit Text is have the value of the item from list and the error isCastparameter to java.lang.Charsequencethis error is in AddFlower class where we set the text to go in to editText field @SurajVaishnav
– Arvind
Nov 16 '18 at 6:27
use editText.setText(list.get(position))
– Suraj Vaishnav
Nov 16 '18 at 6:29
Yes, it is working, but after saving the 1st item, I want the editText to be filled with the 2nd item from list without going back to the listView. So to that should i use the button's object and can you explain aboutnew FetchDataTask().execute(URL);,
– Arvind
Nov 16 '18 at 6:36
like I mean after ,editText.setText(list.get(position)); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // What should I write here// } });
– Arvind
Nov 16 '18 at 6:40
|
show 15 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331642%2fandroid-get-next-item-from-listview-to-edittext-after-1st-item-is-saved%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Pass your data from activity like this
ArrayList<String> tutorialList = new ArrayList<String>();
Intent intent = new Intent(ActivityName.this, Second.class);
intent.putStringArrayListExtra("key", tutorialList);
startActivity(intent);
To retrive at AddFlowerInfo
Intent i = getIntent();
ArrayList<String> list = i.getStringArrayListExtra("key");
Then as you are retrieving data from list using position ,each time after saving call data at next position
1
One concern I see with this approach is that when the user returns to the previous activity it will have old/stale data, not the one that's been edited.
– Kaustuv
Nov 16 '18 at 5:19
@Kaustuv that's correct but that can be handled if he is not calling the Json data once again rather get the data from database
– Jins Lukose
Nov 16 '18 at 5:26
@JinsLukose if I do this, in AddFlowerInfo, It is showing error on lineeditText.setText(list). It is sayingcast parameter to 'java.lang.CharSequence', Then after I did, the app is showing an exception likejava.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app.listview/com.example.app.listview.AddFlowerInfo}: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.CharSequence
– Arvind
Nov 16 '18 at 6:23
@JinsLukose can you help me out?
– Arvind
Nov 16 '18 at 8:12
the below answer is actually correct. anyway let me check
– Jins Lukose
Nov 16 '18 at 8:39
add a comment |
Pass your data from activity like this
ArrayList<String> tutorialList = new ArrayList<String>();
Intent intent = new Intent(ActivityName.this, Second.class);
intent.putStringArrayListExtra("key", tutorialList);
startActivity(intent);
To retrive at AddFlowerInfo
Intent i = getIntent();
ArrayList<String> list = i.getStringArrayListExtra("key");
Then as you are retrieving data from list using position ,each time after saving call data at next position
1
One concern I see with this approach is that when the user returns to the previous activity it will have old/stale data, not the one that's been edited.
– Kaustuv
Nov 16 '18 at 5:19
@Kaustuv that's correct but that can be handled if he is not calling the Json data once again rather get the data from database
– Jins Lukose
Nov 16 '18 at 5:26
@JinsLukose if I do this, in AddFlowerInfo, It is showing error on lineeditText.setText(list). It is sayingcast parameter to 'java.lang.CharSequence', Then after I did, the app is showing an exception likejava.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app.listview/com.example.app.listview.AddFlowerInfo}: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.CharSequence
– Arvind
Nov 16 '18 at 6:23
@JinsLukose can you help me out?
– Arvind
Nov 16 '18 at 8:12
the below answer is actually correct. anyway let me check
– Jins Lukose
Nov 16 '18 at 8:39
add a comment |
Pass your data from activity like this
ArrayList<String> tutorialList = new ArrayList<String>();
Intent intent = new Intent(ActivityName.this, Second.class);
intent.putStringArrayListExtra("key", tutorialList);
startActivity(intent);
To retrive at AddFlowerInfo
Intent i = getIntent();
ArrayList<String> list = i.getStringArrayListExtra("key");
Then as you are retrieving data from list using position ,each time after saving call data at next position
Pass your data from activity like this
ArrayList<String> tutorialList = new ArrayList<String>();
Intent intent = new Intent(ActivityName.this, Second.class);
intent.putStringArrayListExtra("key", tutorialList);
startActivity(intent);
To retrive at AddFlowerInfo
Intent i = getIntent();
ArrayList<String> list = i.getStringArrayListExtra("key");
Then as you are retrieving data from list using position ,each time after saving call data at next position
answered Nov 16 '18 at 5:14
Jins LukoseJins Lukose
746417
746417
1
One concern I see with this approach is that when the user returns to the previous activity it will have old/stale data, not the one that's been edited.
– Kaustuv
Nov 16 '18 at 5:19
@Kaustuv that's correct but that can be handled if he is not calling the Json data once again rather get the data from database
– Jins Lukose
Nov 16 '18 at 5:26
@JinsLukose if I do this, in AddFlowerInfo, It is showing error on lineeditText.setText(list). It is sayingcast parameter to 'java.lang.CharSequence', Then after I did, the app is showing an exception likejava.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app.listview/com.example.app.listview.AddFlowerInfo}: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.CharSequence
– Arvind
Nov 16 '18 at 6:23
@JinsLukose can you help me out?
– Arvind
Nov 16 '18 at 8:12
the below answer is actually correct. anyway let me check
– Jins Lukose
Nov 16 '18 at 8:39
add a comment |
1
One concern I see with this approach is that when the user returns to the previous activity it will have old/stale data, not the one that's been edited.
– Kaustuv
Nov 16 '18 at 5:19
@Kaustuv that's correct but that can be handled if he is not calling the Json data once again rather get the data from database
– Jins Lukose
Nov 16 '18 at 5:26
@JinsLukose if I do this, in AddFlowerInfo, It is showing error on lineeditText.setText(list). It is sayingcast parameter to 'java.lang.CharSequence', Then after I did, the app is showing an exception likejava.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app.listview/com.example.app.listview.AddFlowerInfo}: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.CharSequence
– Arvind
Nov 16 '18 at 6:23
@JinsLukose can you help me out?
– Arvind
Nov 16 '18 at 8:12
the below answer is actually correct. anyway let me check
– Jins Lukose
Nov 16 '18 at 8:39
1
1
One concern I see with this approach is that when the user returns to the previous activity it will have old/stale data, not the one that's been edited.
– Kaustuv
Nov 16 '18 at 5:19
One concern I see with this approach is that when the user returns to the previous activity it will have old/stale data, not the one that's been edited.
– Kaustuv
Nov 16 '18 at 5:19
@Kaustuv that's correct but that can be handled if he is not calling the Json data once again rather get the data from database
– Jins Lukose
Nov 16 '18 at 5:26
@Kaustuv that's correct but that can be handled if he is not calling the Json data once again rather get the data from database
– Jins Lukose
Nov 16 '18 at 5:26
@JinsLukose if I do this, in AddFlowerInfo, It is showing error on line
editText.setText(list). It is saying cast parameter to 'java.lang.CharSequence', Then after I did, the app is showing an exception like java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app.listview/com.example.app.listview.AddFlowerInfo}: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.CharSequence– Arvind
Nov 16 '18 at 6:23
@JinsLukose if I do this, in AddFlowerInfo, It is showing error on line
editText.setText(list). It is saying cast parameter to 'java.lang.CharSequence', Then after I did, the app is showing an exception like java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app.listview/com.example.app.listview.AddFlowerInfo}: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.CharSequence– Arvind
Nov 16 '18 at 6:23
@JinsLukose can you help me out?
– Arvind
Nov 16 '18 at 8:12
@JinsLukose can you help me out?
– Arvind
Nov 16 '18 at 8:12
the below answer is actually correct. anyway let me check
– Jins Lukose
Nov 16 '18 at 8:39
the below answer is actually correct. anyway let me check
– Jins Lukose
Nov 16 '18 at 8:39
add a comment |
You need to send complete array to AddFlowerInfo with the position, so change your onItemClick code:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent(MainActivity.this, AddFlowerInfo.class);
intent.putExtra("position", i);
intent.putStringArrayListExtra("array",tutorialList);
startActivity(intent);
}
});
Now in AddFlowerInfo:
Intent i = getIntent();
ArrayList<String> tutorialList = i.getStringArrayListExtra("array");
int pos=i.getIntExtra("position",0);
Use this position to get item from tutorialList.
To update data when user gets back to previous activity, place this code:
new FetchDataTask().execute(URL);
into onResume method.
Update
After saving first item to edit second item use:
++pos;
if(pos<=tutorialList.size()-1)
editText.setText(tutorialList.get(pos));
else
{
// you are after last item do whatever you want
}
Instead of fetching everytime in onResume, won't it be better to start AddFlowerInfo activity for result, then onActivityResult fetch data if result=OK. This will prevent unnecessary fetching of data, say when coming from screen unlock.
– Kaustuv
Nov 16 '18 at 5:43
It is showing me error on lineeditText.setText(list). Here edit Text is have the value of the item from list and the error isCastparameter to java.lang.Charsequencethis error is in AddFlower class where we set the text to go in to editText field @SurajVaishnav
– Arvind
Nov 16 '18 at 6:27
use editText.setText(list.get(position))
– Suraj Vaishnav
Nov 16 '18 at 6:29
Yes, it is working, but after saving the 1st item, I want the editText to be filled with the 2nd item from list without going back to the listView. So to that should i use the button's object and can you explain aboutnew FetchDataTask().execute(URL);,
– Arvind
Nov 16 '18 at 6:36
like I mean after ,editText.setText(list.get(position)); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // What should I write here// } });
– Arvind
Nov 16 '18 at 6:40
|
show 15 more comments
You need to send complete array to AddFlowerInfo with the position, so change your onItemClick code:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent(MainActivity.this, AddFlowerInfo.class);
intent.putExtra("position", i);
intent.putStringArrayListExtra("array",tutorialList);
startActivity(intent);
}
});
Now in AddFlowerInfo:
Intent i = getIntent();
ArrayList<String> tutorialList = i.getStringArrayListExtra("array");
int pos=i.getIntExtra("position",0);
Use this position to get item from tutorialList.
To update data when user gets back to previous activity, place this code:
new FetchDataTask().execute(URL);
into onResume method.
Update
After saving first item to edit second item use:
++pos;
if(pos<=tutorialList.size()-1)
editText.setText(tutorialList.get(pos));
else
{
// you are after last item do whatever you want
}
Instead of fetching everytime in onResume, won't it be better to start AddFlowerInfo activity for result, then onActivityResult fetch data if result=OK. This will prevent unnecessary fetching of data, say when coming from screen unlock.
– Kaustuv
Nov 16 '18 at 5:43
It is showing me error on lineeditText.setText(list). Here edit Text is have the value of the item from list and the error isCastparameter to java.lang.Charsequencethis error is in AddFlower class where we set the text to go in to editText field @SurajVaishnav
– Arvind
Nov 16 '18 at 6:27
use editText.setText(list.get(position))
– Suraj Vaishnav
Nov 16 '18 at 6:29
Yes, it is working, but after saving the 1st item, I want the editText to be filled with the 2nd item from list without going back to the listView. So to that should i use the button's object and can you explain aboutnew FetchDataTask().execute(URL);,
– Arvind
Nov 16 '18 at 6:36
like I mean after ,editText.setText(list.get(position)); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // What should I write here// } });
– Arvind
Nov 16 '18 at 6:40
|
show 15 more comments
You need to send complete array to AddFlowerInfo with the position, so change your onItemClick code:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent(MainActivity.this, AddFlowerInfo.class);
intent.putExtra("position", i);
intent.putStringArrayListExtra("array",tutorialList);
startActivity(intent);
}
});
Now in AddFlowerInfo:
Intent i = getIntent();
ArrayList<String> tutorialList = i.getStringArrayListExtra("array");
int pos=i.getIntExtra("position",0);
Use this position to get item from tutorialList.
To update data when user gets back to previous activity, place this code:
new FetchDataTask().execute(URL);
into onResume method.
Update
After saving first item to edit second item use:
++pos;
if(pos<=tutorialList.size()-1)
editText.setText(tutorialList.get(pos));
else
{
// you are after last item do whatever you want
}
You need to send complete array to AddFlowerInfo with the position, so change your onItemClick code:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Intent intent = new Intent(MainActivity.this, AddFlowerInfo.class);
intent.putExtra("position", i);
intent.putStringArrayListExtra("array",tutorialList);
startActivity(intent);
}
});
Now in AddFlowerInfo:
Intent i = getIntent();
ArrayList<String> tutorialList = i.getStringArrayListExtra("array");
int pos=i.getIntExtra("position",0);
Use this position to get item from tutorialList.
To update data when user gets back to previous activity, place this code:
new FetchDataTask().execute(URL);
into onResume method.
Update
After saving first item to edit second item use:
++pos;
if(pos<=tutorialList.size()-1)
editText.setText(tutorialList.get(pos));
else
{
// you are after last item do whatever you want
}
edited Nov 16 '18 at 7:31
answered Nov 16 '18 at 5:25
Suraj VaishnavSuraj Vaishnav
1,8742620
1,8742620
Instead of fetching everytime in onResume, won't it be better to start AddFlowerInfo activity for result, then onActivityResult fetch data if result=OK. This will prevent unnecessary fetching of data, say when coming from screen unlock.
– Kaustuv
Nov 16 '18 at 5:43
It is showing me error on lineeditText.setText(list). Here edit Text is have the value of the item from list and the error isCastparameter to java.lang.Charsequencethis error is in AddFlower class where we set the text to go in to editText field @SurajVaishnav
– Arvind
Nov 16 '18 at 6:27
use editText.setText(list.get(position))
– Suraj Vaishnav
Nov 16 '18 at 6:29
Yes, it is working, but after saving the 1st item, I want the editText to be filled with the 2nd item from list without going back to the listView. So to that should i use the button's object and can you explain aboutnew FetchDataTask().execute(URL);,
– Arvind
Nov 16 '18 at 6:36
like I mean after ,editText.setText(list.get(position)); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // What should I write here// } });
– Arvind
Nov 16 '18 at 6:40
|
show 15 more comments
Instead of fetching everytime in onResume, won't it be better to start AddFlowerInfo activity for result, then onActivityResult fetch data if result=OK. This will prevent unnecessary fetching of data, say when coming from screen unlock.
– Kaustuv
Nov 16 '18 at 5:43
It is showing me error on lineeditText.setText(list). Here edit Text is have the value of the item from list and the error isCastparameter to java.lang.Charsequencethis error is in AddFlower class where we set the text to go in to editText field @SurajVaishnav
– Arvind
Nov 16 '18 at 6:27
use editText.setText(list.get(position))
– Suraj Vaishnav
Nov 16 '18 at 6:29
Yes, it is working, but after saving the 1st item, I want the editText to be filled with the 2nd item from list without going back to the listView. So to that should i use the button's object and can you explain aboutnew FetchDataTask().execute(URL);,
– Arvind
Nov 16 '18 at 6:36
like I mean after ,editText.setText(list.get(position)); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // What should I write here// } });
– Arvind
Nov 16 '18 at 6:40
Instead of fetching everytime in onResume, won't it be better to start AddFlowerInfo activity for result, then onActivityResult fetch data if result=OK. This will prevent unnecessary fetching of data, say when coming from screen unlock.
– Kaustuv
Nov 16 '18 at 5:43
Instead of fetching everytime in onResume, won't it be better to start AddFlowerInfo activity for result, then onActivityResult fetch data if result=OK. This will prevent unnecessary fetching of data, say when coming from screen unlock.
– Kaustuv
Nov 16 '18 at 5:43
It is showing me error on line
editText.setText(list). Here edit Text is have the value of the item from list and the error is Castparameter to java.lang.Charsequence this error is in AddFlower class where we set the text to go in to editText field @SurajVaishnav– Arvind
Nov 16 '18 at 6:27
It is showing me error on line
editText.setText(list). Here edit Text is have the value of the item from list and the error is Castparameter to java.lang.Charsequence this error is in AddFlower class where we set the text to go in to editText field @SurajVaishnav– Arvind
Nov 16 '18 at 6:27
use editText.setText(list.get(position))
– Suraj Vaishnav
Nov 16 '18 at 6:29
use editText.setText(list.get(position))
– Suraj Vaishnav
Nov 16 '18 at 6:29
Yes, it is working, but after saving the 1st item, I want the editText to be filled with the 2nd item from list without going back to the listView. So to that should i use the button's object and can you explain about
new FetchDataTask().execute(URL);,– Arvind
Nov 16 '18 at 6:36
Yes, it is working, but after saving the 1st item, I want the editText to be filled with the 2nd item from list without going back to the listView. So to that should i use the button's object and can you explain about
new FetchDataTask().execute(URL);,– Arvind
Nov 16 '18 at 6:36
like I mean after ,
editText.setText(list.get(position)); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // What should I write here// } });– Arvind
Nov 16 '18 at 6:40
like I mean after ,
editText.setText(list.get(position)); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // What should I write here// } });– Arvind
Nov 16 '18 at 6:40
|
show 15 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331642%2fandroid-get-next-item-from-listview-to-edittext-after-1st-item-is-saved%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
so are passing one string at a time to AddFlowerInfo activity.right?
– Jins Lukose
Nov 16 '18 at 5:00
yes @JinsLukose
– Arvind
Nov 16 '18 at 5:01
so you have to save all data to string array and pass it to AddFlowerInfo activity
– Jins Lukose
Nov 16 '18 at 5:03
Yes @JinsLukose , but I am not able to figure it out how to do it?
– Arvind
Nov 16 '18 at 5:04
Can you write it for me, Because cannot understand that part
– Arvind
Nov 16 '18 at 5:05