【发布时间】:2021-01-13 01:43:56
【问题描述】:
我无法得到它我已经尝试过 appcompat 之类的东西,但没有奏效。不知道怎么解决。
public class MainActivity extends AppCompatActivity {
private Button button;
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = findViewById(R.id.showName); ---> Here it is giving the problem.
textView = findViewById(R.id.textView);
textView.setText("Hello from Java!!");
}
}
【问题讨论】:
-
上传你的xml
-
请发布您的 xml,然后我可以找出您的错误。
-
既然你想通了,而且没有足够的信息来回答这个问题,请考虑删除你的问题。或者,edit您的问题以包含信息,然后发布您的答案。谢谢。
-
是的,谢谢我明白了。它是 textView。我现在已将其转换为 Button。