Created
September 12, 2018 03:21
-
-
Save springcome/8b78c76fddefbeef09c9ada86d6bfd56 to your computer and use it in GitHub Desktop.
AppCompatActivit를 상속하지 않은 class에서 findViewByID를 사용하고자 할때
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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