我明白了:
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[]*
我基本上只想发布我的数组。
答案 0 :(得分:1)
View[] android
而不是View android[]
。
使它成为
View[] android = new View[6];
答案 1 :(得分:0)
android
是View
的数组。
*Incompatible types
Required android.view.View
Found android.view.View[]*
你正在使用的函数有一个返回类型android.view.View,而不是一个Views(android.view.View[]
)数组。
如果这不是必须与定义匹配的重写函数,则可以将函数定义更改为android.view.View[]
。
否则,您需要返回android
元素,即android[0]