Home > Mobile >  Call the findViewById outside class
Call the findViewById outside class

Time:12-26

Android beginners, I'd like to outer class (used in response to a button control) to invoke the findViewById interface found in controls, the results found no
The import android. Widget. The EditText;
The import android. Widget. Spinner.

Public class BTListerner extends the Activity implements the View. An OnClickListener {
Public void onClick (View View)
{
The EditText edtText;
The switch (the getId ())
{
Case R.i db tn_delDev:
EdtText=the findViewById (R.i d.e dt_devScan);
EdtText. SetText (" ");
break;
Case R.i db tn_delKnife:
EdtText=the findViewById (R.i d.e dt_KnifeScan);
EdtText. SetText (" ");
}

CodePudding user response:

There are several measures, such as the callback, the inner class reference directly, the incoming handler, and novices are most likely to use EventBus,

CodePudding user response:

I said is to achieve the purpose of you oh, not external calls the findViewById
  • Related