FindViewById()不在主Activity.cs

时间:2017-08-09 20:25:37

标签: android xamarin

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minWidth="25px"
    android:minHeight="25px">
    <Button
        android:text="Button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/button1" />
</LinearLayout>

我想访问Main Activity.cs中的“Resource.Id”,但是当我编写代码时,请遵循:

 $Button button = Findviewbyid <Button> (Resource.)

我无法访问“ID”,为什么!!怎么样?

1 个答案:

答案 0 :(得分:0)

资源被编译为“R”,而不是“资源”。你需要这样做:

DispatchQueue.main.async() {
    self.tableView.reloadData()
}