android-asynctask

Failing to update the table based on checked value

。_饼干妹妹 提交于 2020-01-30 11:57:27
问题 I've a listview from the database with checkbox. My objectives is to insert the checked listview into a table and update another table based on the checked listview . Unfortunately, my SQL query did not work in the section. Here is my code to insert the checked listview into BRTR table and update rows in WORKTR table based on the checked listview: // Get Item Checked Button btnGetItem = (Button) findViewById(R.id.btnGetItem); btnGetItem.setOnClickListener(new OnClickListener() { public void

How to get a string back from AsyncTask?

笑着哭i 提交于 2020-01-27 03:56:38
问题 I have the following class: public class getURLData extends AsyncTask<String, Integer, String>{ @Override protected String doInBackground(String... params) { String line; try { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(params[0]); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); line = EntityUtils.toString(httpEntity); } catch (UnsupportedEncodingException e) { line = "<results status=\

How to get a string back from AsyncTask?

只愿长相守 提交于 2020-01-27 03:54:24
问题 I have the following class: public class getURLData extends AsyncTask<String, Integer, String>{ @Override protected String doInBackground(String... params) { String line; try { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(params[0]); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); line = EntityUtils.toString(httpEntity); } catch (UnsupportedEncodingException e) { line = "<results status=\

Android show back button depending on backstack count

不想你离开。 提交于 2020-01-26 04:27:29
问题 I want to show or hide the back button of the action bar depending on the current backstack entry count. That means I want to show it when there is a fragment (or more) in the backstack, and hide when backstack is empty getSupportActionBar().setDisplayHomeAsUpEnabled(b); The problem is, when I start a new fragment and ask for the current backstack entry count, it's still the same like before. It refreshes after some milliseconds. Also in the started fragment's onResume method, the replaced

Android show back button depending on backstack count

馋奶兔 提交于 2020-01-26 04:27:13
问题 I want to show or hide the back button of the action bar depending on the current backstack entry count. That means I want to show it when there is a fragment (or more) in the backstack, and hide when backstack is empty getSupportActionBar().setDisplayHomeAsUpEnabled(b); The problem is, when I start a new fragment and ask for the current backstack entry count, it's still the same like before. It refreshes after some milliseconds. Also in the started fragment's onResume method, the replaced

change single item listview android with asynctask

旧时模样 提交于 2020-01-25 16:39:46
问题 I'm learning how to change single item custom listview android with AsyncTask, I've followed this tutorial. but it's seem not work in my listview. this my code private class ViewHolder { public ImageButton favorite; public TextView jmlh_favorite; protected int position; } public View getView(final int position, View convertView, ViewGroup parent) { View vi = convertView; final ViewHolder holder; if (convertView == null) { vi = inflater.inflate(R.layout.laporan_list_item, null); holder = new

change single item listview android with asynctask

旧城冷巷雨未停 提交于 2020-01-25 16:37:07
问题 I'm learning how to change single item custom listview android with AsyncTask, I've followed this tutorial. but it's seem not work in my listview. this my code private class ViewHolder { public ImageButton favorite; public TextView jmlh_favorite; protected int position; } public View getView(final int position, View convertView, ViewGroup parent) { View vi = convertView; final ViewHolder holder; if (convertView == null) { vi = inflater.inflate(R.layout.laporan_list_item, null); holder = new

Why could onPostExecute run before doInBackground in AsyncTask?

随声附和 提交于 2020-01-25 13:05:32
问题 When I debug my app I see that onPostExecute starts after onPreExecute and only when it is finished doInBackground method start running, so I don't have results on UI. Why it could be? AsyncTask code: class TranslateYandex extends AsyncTask<Void, Void, Void> { String translate = ""; // YandexTranslation yandexTranslation; @Override protected void onPreExecute() { super.onPreExecute(); enterWord.setEnabled(false); getTranslateButton.setEnabled(false); translate = enterWord.getText().toString()

How to disable button in RecyclerView and from AsyncTask

让人想犯罪 __ 提交于 2020-01-25 09:32:07
问题 I am trying to disable button after click in RecyclerView from Retrofit response. Application is using RecyclerView to populate list and I am using Retrofit to communicate to back-end REST API. There are two buttons inside one item and Retrofit client is activated on click. And if response from API is successful button should be disabled. I came across on two problems: first few items works just fine, but after few scrolls buttons I have never clicked on are disabled also; second was that

How to get AsyncTask Completed Status From Non Activity Class

自作多情 提交于 2020-01-25 07:18:49
问题 I want to wait until my AsynTask is finished before continuing on. The status always shows as RUNNING however. How can the AsyncTask signal back that is has finished? Why is my while loop endless? I thought that once onPostExecute() is called on the task the status gets changed to FINISHED. private void methodOne(Context context) { MyNewTask getMyTask = null; try { getMyTask = new MyNewTask(context, null, null, param1); getMyTask.execute(getUrl()); while(getResourceTask.getStatus().equals