Reputation:
I am learning AsyncTask
. I want to add a TextView like Loading.... while AyncTask Working. How can I do this
Below is the code
public class MainActivity extends AppCompatActivity {
private EditText et_bookInput;
private TextView tv_titleText;
private TextView tv_authorText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et_bookInput = findViewById(R.id.bookInput);
tv_titleText = findViewById(R.id.titleText);
tv_authorText = findViewById(R.id.authorText);
}
public void searchBooks(View view) {
// Get the name of the book from the input field
String queryString = et_bookInput.getText().toString();
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if(inputMethodManager != null){
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
new FetchBook(tv_titleText, tv_authorText).execute(queryString);
}
Upvotes: 1
Views: 37
Reputation:
I have tested you code and you need to set the loading
Text just inside your searchBooks(View view)
TextView.setText("Loading...")
Upvotes: 0
Reputation: 1336
Try the following code:
tv_authorText.setText("");
tv_titleText.setText(R.string.loding);
I assumed that at tv_titleText
you want to add loading Text.
Upvotes: 1