【发布时间】:2023-04-08 07:32:01
【问题描述】:
好吧,让我更好地解释一下。 我想制作一个应用程序,它具有特定的问题和答案集作为 textview 和 edittext,并且在后端我有两列名为问题和答案。我想在问题列中插入所有 textview(question),在答案列中插入所有 edittext(answers)。我可以一次插入一行,但不能在单击按钮时一次插入所有行。
public void SendDataToServer(final String name, final String email, final String website){
class SendPostReqAsyncTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
String QuickName = name ;
String QuickEmail = email ;
String QuickWebsite = website;
//String[] str = {QuickName,QuickEmail,QuickWebsite};
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("name", QuickName));
//nameValuePairs.add(new BasicNameValuePair("name", email));
nameValuePairs.add(new BasicNameValuePair("email", QuickEmail));
nameValuePairs.add(new BasicNameValuePair("website", QuickWebsite));
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(DataParseUrl);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
return "Data Submit Successfully";
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
Toast.makeText(MainActivity.this, "Data Submit Successfully", Toast.LENGTH_LONG).show();
}
}
SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();
sendPostReqAsyncTask.execute(name, email, website);
}
【问题讨论】: