我有一个线性布局,在屏幕上显示完整列表,没有列表滚动。我使用listview但是无法同时显示所有项目而没有滚动。现在我想在线性布局中将粘贴标题视图添加到此列表我应该选择哪种方法?
l1= (LinearLayout) findViewById(R.id.list1);
l2= (LinearLayout) findViewById(R.id.list2);
retrofit=new Retrofit.Builder().baseUrl("http://taskism.com").addConverterFactory(GsonConverterFactory.create()).build();
Login_api newcall=retrofit.create(Login_api.class);
Call<inst_model> mycall=newcall.gettasksteplist("tasksteplist","223","62");
mycall.enqueue(new Callback<inst_model>() {
@Override
public void onResponse(Response<inst_model> response, Retrofit retrofit) {
progressDialog.setIndeterminate(false);
progressDialog.dismiss();
tasksteps=response.body().getTasksteps();
adapter1=new adapter1(instructions.this,R.layout.adapter1,tasksteps);
for (int i = 0; i < adapter1.getCount(); i++) {
View view = adapter1.getView(i, null, l1);
l1.addView(view);
}
}
@Override
public void onFailure(Throwable t) {
}
});
Login_api allcomnt=retrofit.create(Login_api.class);
Call<Commentall> allcomm=allcomnt.commentall("commentall", "222", "14");
allcomm.enqueue(new Callback<Commentall>() {
@Override
public void onResponse(Response<Commentall> response, Retrofit retrofit) {
List<Comment> allcom=response.body().getComments();
adapter2 =new adapter2(instructions.this,R.layout.adapter2,allcom);
for (int i = 0; i < adapter2.getCount(); i++) {
View view = adapter2.getView(i, null, l2);
l2.addView(view);
}
}
@Override
public void onFailure(Throwable t) {
}
});
}
,布局如下
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:id="@+id/instname"
android:textColor="@android:color/black"
android:layout_marginBottom="10dp"
android:text="Gairy J"
android:gravity="center_horizontal"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/steps"
android:text="Steps"
android:src="@drawable/icon_cancel"
android:textColor="@android:color/holo_green_light"
android:gravity="center_horizontal"
android:layout_below="@id/instname"/>
<LinearLayout
android:layout_below="@id/steps"
android:layout_width="match_parent"
android:id="@+id/list1"
android:orientation="vertical"
android:dividerHeight="1dp"
android:layout_height="wrap_content">
</LinearLayout>
<TextView
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Comments"
android:id="@+id/comment"
android:gravity="center_horizontal"
android:textColor="@android:color/holo_green_light"
android:layout_below="@id/list1"
android:layout_marginBottom="10dp"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:id="@+id/list2"
android:layout_marginLeft="10dp"
android:dividerHeight="1dp"
android:layout_below="@id/comment"
android:layout_height="wrap_content">
</LinearLayout>
</RelativeLayout>
</ScrollView>
答案 0 :(得分:0)
<Scrollview>
<---Header Layout-->
<ListView/>
</scrollview>
答案 1 :(得分:0)
您可以使用此库添加粘性标题和其他