Я использую представление списка в своей активности фрагмента. Я не знаю, почему этот дополнительный космический фон отображается в конце моего списка. Все элементы отображаются правильно, но представление списка показывает мне фон в конце списка, как показано на рисунке ниже, который я не хочу показывать; Пожалуйста, помогите мне.
мой макет xml код:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Fragments.TimeSheetFragment">
<LinearLayout
android:layout_width="match_parent"
android:weightSum="3"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:background="@drawable/bg"
android:layout_height="0dp">
<TextView
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/timesheetW"
android:textColor="@color/colorWhite"
android:textSize="@dimen/_20sdp"
android:fontFamily="@font/sfcompacttextmedium"
android:layout_marginTop="@dimen/_20sdp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="2">
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/rel_t_main"
android:layout_width="wrap_content"
android:background="@drawable/currentmonthbg"
android:layout_marginTop="@dimen/_80sdp"
android:layout_height="@dimen/_170sdp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="October 2019"
android:id="@+id/month_timesheet"
android:textStyle="bold"
android:textSize="@dimen/_14sdp"
android:fontFamily="@font/sfcompacttextmedium"
android:textColor="@color/colorBlack"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_30sdp"
/>
<ImageView
android:id="@+id/warning_img"
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:src="@drawable/warning"
android:layout_alignParentRight="true"
android:layout_marginTop="@dimen/_20sdp"
android:layout_marginRight="@dimen/_20sdp"
/>
<LinearLayout
android:id="@+id/lin_timesheet_pics"
android:layout_below="@+id/warning_img"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/_20sdp"
android:layout_marginRight="@dimen/_35sdp"
android:layout_marginLeft="@dimen/_50sdp"
android:orientation="horizontal"
android:layout_height="wrap_content">
<ImageView
android:layout_width="@dimen/_55sdp"
android:layout_height="@dimen/_52sdp"
android:id="@+id/timeWorkDaysIcon"
android:src="@drawable/workdaysicon"
android:layout_marginRight="@dimen/_10sdp"
/>
<ImageView
android:layout_marginRight="@dimen/_10sdp"
android:src="@drawable/borderlarge"
android:layout_width="wrap_content"
android:layout_height="@dimen/_50sdp"
/>
<ImageView
android:layout_marginRight="@dimen/_10sdp"
android:layout_width="@dimen/_50sdp"
android:id="@+id/timeLeavesIcon"
android:layout_height="@dimen/_50sdp"
android:src="@drawable/leavesicon"
/>
<ImageView
android:layout_marginRight="@dimen/_10sdp"
android:layout_width="wrap_content"
android:src="@drawable/borderlarge"
android:layout_height="@dimen/_50sdp"
/>
<ImageView
android:layout_width="@dimen/_50sdp"
android:id="@+id/timeSicknessIcon"
android:layout_height="@dimen/_50sdp"
android:src="@drawable/sickness"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/lin_timesheet_text"
android:layout_below="@id/lin_timesheet_pics"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/_10sdp"
android:layout_marginRight="@dimen/_35sdp"
android:layout_marginLeft="@dimen/_40sdp"
android:orientation="horizontal"
android:layout_height="wrap_content">
<TextView
android:layout_width="@dimen/_60sdp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/_15sdp"
android:text="25"
android:id="@+id/txtWorkDays"
android:fontFamily="@font/sfcompacttextsemibold"
android:textColor="@color/colorBlue"
android:textSize="@dimen/_14sdp"
android:gravity="center_horizontal"
/>
<ImageView
android:layout_marginRight="@dimen/_10sdp"
android:src="@drawable/bordersmall"
android:layout_width="wrap_content"
android:layout_height="@dimen/_14sdp"
/>
<TextView
android:fontFamily="@font/sfcompacttextsemibold"
android:textColor="@color/colorGreen"
android:layout_marginRight="@dimen/_1sdp"
android:layout_width="@dimen/_60sdp"
android:layout_height="wrap_content"
android:text="07"
android:id="@+id/txtLeaves"
android:textSize="@dimen/_14sdp"
android:gravity="center_horizontal"
/>
<ImageView
android:layout_marginRight="@dimen/_10sdp"
android:layout_width="wrap_content"
android:src="@drawable/bordersmall"
android:layout_height="@dimen/_14sdp"
/>
<TextView
android:fontFamily="@font/sfcompacttextsemibold"
android:textColor="@color/colorOrange"
android:layout_width="@dimen/_60sdp"
android:layout_height="wrap_content"
android:text="04"
android:id="@+id/txtSickness"
android:textSize="@dimen/_14sdp"
android:gravity="center_horizontal"
/>
</LinearLayout>
</RelativeLayout>
<ListView
android:layout_below="@+id/rel_t_main"
android:layout_above="@+id/footer_lv"
android:id="@+id/listViewTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:drawSelectorOnTop="false"
android:fadingEdge="vertical"
android:padding="5dp"
android:scrollbars="none"
android:smoothScrollbar="true"
android:soundEffectsEnabled="true"
/>
<RelativeLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:id="@+id/footer_lv"
android:background="@drawable/menubgg"
android:layout_height="@dimen/_50sdp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/back"
android:id="@+id/backTm"
android:layout_alignParentLeft="true"
/>
<ImageView
android:id="@+id/addTm"
android:layout_marginTop="@dimen/_5sdp"
android:layout_width="@dimen/_50sdp"
android:layout_height="@dimen/_50sdp"
android:layout_centerHorizontal="true"
android:src="@drawable/add"
/>
<ImageView
android:id="@+id/menuTm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menuicon"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
</RelativeLayout>
мой код адаптера:
package com.ndbsoft.cozati.Adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.ndbsoft.cozati.Models.Timesheet;
import com.ndbsoft.cozati.R;
import com.ndbsoft.cozati.utils;
import java.util.List;
public class AdapterTimesheetList extends BaseAdapter {
String monthName;
private Context context;
private List<Timesheet> timelist;
public AdapterTimesheetList(Context context, List<Timesheet> timelist) {
this.context = context;
this.timelist = timelist;
}
@Override
public int getCount() {
return timelist.size();
}
@Override
public Object getItem(int position) {
return timelist.get(position);
}
@Override
public long getItemId(int position) {
return timelist.get(position).getTimeSheetId();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view33= LayoutInflater.from(parent.getContext()).inflate(R.layout.timesheet_list_item,parent,false);
Timesheet timeSheett=timelist.get(position);
if (timelist.get(position).getStatusCode().equals("timesheet-waiting_validation")){
if (utils.lang.equals("fr")){
((RelativeLayout)view33.findViewById(R.id.background_timesheet_list)).setBackgroundResource(R.drawable.draft_list_bg_fr);
}else if (utils.lang.equals("en")){
((RelativeLayout)view33.findViewById(R.id.background_timesheet_list)).setBackgroundResource(R.drawable.draft_list_bg);
}
}
else if (timelist.get(position).getStatusCode().equals("timesheet-manager-approved")){
if (utils.lang.equals("fr")){
((RelativeLayout)view33.findViewById(R.id.background_timesheet_list)).setBackgroundResource(R.drawable.approved_list_bg_fr);
}else if (utils.lang.equals("en")){
((RelativeLayout)view33.findViewById(R.id.background_timesheet_list)).setBackgroundResource(R.drawable.approved_list_bg);
}
}
else if (timelist.get(position).getStatusCode().equals("timesheet-refused")){
if (utils.lang.equals("fr")){
((RelativeLayout)view33.findViewById(R.id.background_timesheet_list)).setBackgroundResource(R.drawable.refused_list_bg_fr);
}else if (utils.lang.equals("en")){
((RelativeLayout)view33.findViewById(R.id.background_timesheet_list)).setBackgroundResource(R.drawable.refused_list_bg);
}
}
else {
}
// String monthname=(String)android.text.format.DateFormat.format("MMMM yyyy", new Date());
// Calendar calendar = Calendar.getInstance();
Timesheet timesheetObj = timelist.get(position);
String month = String.valueOf(timesheetObj.getMonth());
if (month.equals("1")){
monthName = context.getResources().getString(R.string.janu);
}
else if (month.equals("2")){
monthName = context.getResources().getString(R.string.feb);
}
else if (month.equals("3")){
monthName = context.getResources().getString(R.string.march);
}
else if (month.equals("4")){
monthName = context.getResources().getString(R.string.april);
}
else if (month.equals("5")){
monthName = context.getResources().getString(R.string.may);
}
else if (month.equals("6")){
monthName = context.getResources().getString(R.string.june);
}
else if (month.equals("7")){
monthName = context.getResources().getString(R.string.july);
}
else if (month.equals("8")){
monthName = context.getResources().getString(R.string.aug);
}
else if (month.equals("9")){
monthName = context.getResources().getString(R.string.sept);
}
else if (month.equals("10")){
monthName = context.getResources().getString(R.string.octo);
}
else if (month.equals("11")){
monthName = context.getResources().getString(R.string.nov);
}
else if (month.equals("12")){
monthName = context.getResources().getString(R.string.decm);
}
((TextView)view33.findViewById(R.id.txt_date_li)).setText("Timesheet "+monthName +" "+timesheetObj.getYear());
((TextView)view33.findViewById(R.id.txt_mission_li2)).setText(String.valueOf( " " +timeSheett.getMissionName()));
((TextView)view33.findViewById(R.id.txt_workdays_li2)).setText(String.valueOf(timesheetObj.getTotalPresence()));
((TextView)view33.findViewById(R.id.txt_leaves_li2)).setText("0");
((TextView)view33.findViewById(R.id.txt_sickness_li2)).setText("0");
return view33;
}
}
А вот и мой код:
final RequestQueue requestQueue= Volley.newRequestQueue(getContext());
StringRequest stringRequest=new StringRequest(Request.Method.GET, utils.Base_URl+"/timesheet/resource/"+utils.user_detail.getResourceId(),
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONArray jsonArray=new JSONArray(response);
if (jsonArray.length() == 0){
progress.dismiss();
Toast.makeText(getContext(), R.string.listEmpty, Toast.LENGTH_SHORT).show();
}else {
for (int i=0 ; i < jsonArray.length() ; i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
int timesheetId=jsonObject.getInt("timesheetId");
if (jsonObject.getString("resourceId") == null){
resourceId = 0;
}
else if (jsonObject.getString("resourceId").equals("null")){
resourceId = 0;
}
else {
resourceId = Integer.parseInt(jsonObject.getString("resourceId"));
}
int month=jsonObject.getInt("month");
int year=jsonObject.getInt("year");
// int statusId=jsonObject.getInt("statusId");
if (jsonObject.getString("missionId") == null){
missionId = 0;
}
else if (jsonObject.getString("missionId").equals("null")){
missionId = 0;
}
else {
missionId = Integer.parseInt(jsonObject.getString("missionId"));
}
// int missionId=jsonObject.getInt("missionId");
String firstName=jsonObject.getString("firstName");
String lastName=jsonObject.getString("lastName");
String monthLabel=jsonObject.getString("monthLabel");
String statusCode=jsonObject.getString("statusCode");
String missionName=jsonObject.getString("missionName");
double totalNightShift=jsonObject.getDouble("totalNightShift");
double totalExtraHourNight=jsonObject.getDouble("totalExtraHourNight");
double totalExtraHours=jsonObject.getDouble("totalExtraHours");
double totalPresence=jsonObject.getDouble("totalPresence");
String monthname=(String)android.text.format.DateFormat.format("MMMM yyyy", new Date());
Calendar calendar = Calendar.getInstance();
monthLabel22.setText(monthname);
Timesheet timeSheet = new Timesheet();
timeSheet.setTimeSheetId(timesheetId);
timeSheet.setResourceId(resourceId);
timeSheet .setMonth(month);
timeSheet .setYear(year);
// timeSheet.setStatusId(statusId);
timeSheet .setMissionId(missionId);
timeSheet.setFirstName(firstName);
timeSheet.setLastName(lastName);
timeSheet.setMonthLabel(monthLabel);
timeSheet .setStatusCode(statusCode);
timeSheet.setMissionName(missionName);
timeSheet .setTotalNightShift(totalNightShift);
timeSheet .setTotalExtraHourNight(totalExtraHourNight);
timeSheet.setTotalExtraHours(totalExtraHours);
timeSheet.setTotalPresence(totalPresence);
timeSheetList.add(timeSheet);
timeSheetListTotal.setAdapter(new AdapterTimesheetList(getContext(),timeSheetList));
progress.dismiss();
}
}
}
catch (JSONException e) {
progress.dismiss();
Toast.makeText(getContext(), R.string.someWrong, Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progress.dismiss();
Toast.makeText(getContext(), R.string.someWrong, Toast.LENGTH_SHORT).show();
}
})
{
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Accept","application/json");
headers.put("Authorization",utils.bear+utils.user_token);
return headers;
}
};