Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save springcome/8b78c76fddefbeef09c9ada86d6bfd56 to your computer and use it in GitHub Desktop.
Save springcome/8b78c76fddefbeef09c9ada86d6bfd56 to your computer and use it in GitHub Desktop.
AppCompatActivit를 상속하지 않은 class에서 findViewByID를 사용하고자 할때
public class A {
public static void fillView(Activity activity) {
TextView view = activity.findViewByID(R.id.view);
view.setText('A');
}
}
public class B extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
A.fillView(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment