我想显示从Web服务获取的数据并将其显示在Tab Activity的Fragment中,但无法使用recyclerview或listview。有人可以建议我为此使用什么吗?
Fragment_Layout
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rellay1"
android:layout_marginTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/grey"
android:layout_margin="8dp"
app:cardCornerRadius="10dp"
android:elevation="5dp"
app:cardElevation="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Overdue Enquiry Followups"
android:textSize="18dp"
android:textColor="@color/white"
android:layout_margin="8dp"
/>
<ImageView
android:id="@+id/btn_expand"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/expand"
android:layout_gravity="right"/>
</android.support.design.card.MaterialCardView>
<android.support.design.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/grey"
android:layout_margin="8dp"
app:cardCornerRadius="10dp"
android:elevation="5dp"
app:cardElevation="8dp">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mainmenu"
android:visibility="visible">
</ListView>
</android.support.design.card.MaterialCardView>
</LinearLayout>
</ScrollView>
https://i.stack.imgur.com/e868X.png 这是我要设计的设计样本。
片段Java代码:
@Override
public View onCreateView(
@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_main_tab,container,false);
String [] menuItems={"Do Something","Do something else","Bhad Min ja phir"};
ListView listView=view.findViewById(R.id.mainmenu);
ArrayAdapter<String> listViewAdapter=new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1,menuItems);
listView.setAdapter(listViewAdapter);
View root=null;
switch (getArguments().getInt(ARG_SECTION_NUMBER))
{
case 1:
root = inflater.inflate(R.layout.fragment_main_tab, container, false);
break;
case 2:
root = inflater.inflate(R.layout.fragment_team_screen_, container, false);
break;
}
return root;
}