我得到了这个:
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;..。
View android[] = new View[6];
android[0] = inflater.inflate(R.layout.asd_frag, container, false);
((TextView) android[0].findViewById(R.id.textViewAsd01)).setText("Asd");
((TextView) android[0].findViewById(R.id.game_asd_name_one)).setText("hi");还有这个
android[1] = inflater.inflate(R.layout.qwe_frag, container, false);
((TextView) android[1].findViewById(R.id.textViewQwe01)).setText("qwe");
((TextView) android[1].findViewById(R.id.game_Qwe_name_two)).setText("bye");
return android;当我试图返回这个数组时,我得到了一个奇怪的消息,它说:
*Incompatible types
Required android.view.View
Found android.view.View[]*我基本上只想给出我的数组。
所以我点击了Android Studio的提示,我得到了这个奇怪的错误,

发布于 2015-07-23 10:10:57
在定义变量时,请尝试使用View[] android而不是View android[]。
这使得它
View[] android = new View[6];发布于 2015-07-23 06:53:06
android是一个View数组。
*Incompatible types
Required android.view.View
Found android.view.View[]*您正在使用的函数的返回类型是android.view.View,而不是视图数组(android.view.View[])。
如果这不是必须与定义匹配的重写函数,则可以将函数定义更改为android.view.View[]。
否则,您需要返回一个android元素,即android[0]
https://stackoverflow.com/questions/31574439
复制相似问题