dimanche 4 septembre 2016

How to create a method inside the onPostExecute?

I tried to put if else inside the button onClick

Here's the onClick

@Override
        public void onClick(View view) {
                ettext.getText().toString();
                viewword.getText().toString();
                select();

                if(viewword.equals("")) {

                    Toast.makeText(getBaseContext(), "Does not exist in database.1", Toast.LENGTH_LONG).show();
                }else{
                    sendChatMessage();
                }


        }

Here's the onPostExecute

@Override
        protected void onPostExecute(String result) {
            TextView disp = (TextView) findViewById(R.id.view);
            try {
                JSONObject json_data = new JSONObject(result);
                word = json_data.getString("server_response");
                disp.setText(word);


            } catch (JSONException e) {
                disp.setText("");
            }

        }

The problem is that the app is not reading the if else statement and proceed to onPostExecute. My solution was to create a method inside the onPostExecute but I don't know how.

Aucun commentaire:

Enregistrer un commentaire