【发布时间】:2018-06-06 15:16:22
【问题描述】:
我有以下课程:
public class LineChart extends AppCompatActivity{
private LineChart mChart;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_line_chart);
mChart = findViewById(R.id.linechart);
}
}
还有一个 XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/relativeLayout">
<com.github.mikephil.charting.charts.LineChart
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linechart">
</com.github.mikephil.charting.charts.LineChart>
我现在的问题是,当我尝试使用findViewById(R.id.linechart) 获取折线图时出现错误:
错误:(42, 24) 错误:不兼容的类型:类型变量 T 不存在唯一的最大实例,具有上限 LineChart,View 其中 T 是一个类型变量: T 扩展了方法 findViewById(int) 中声明的 View
如果您查看MPAndroidChart Wiki,您会发现我没有做错任何事情(我希望如此)。有人可以告诉我我的错误在哪里。提前致谢
【问题讨论】: