Browse Source

适配器

master
lh 7 years ago
parent
commit
3e736d08b4
6 changed files with 215 additions and 3 deletions
  1. +61
    -0
      app/src/main/java/com/qhclh/ytzh/bean/ThreeTypeBean.java
  2. +9
    -0
      app/src/main/java/com/qhclh/ytzh/home/RpcUrl.java
  3. +0
    -1
      app/src/main/java/com/qhclh/ytzh/index/fumudai/FumudaiFragment.java
  4. +36
    -2
      app/src/main/java/com/qhclh/ytzh/index/fumudai/ThreeTypeActivity.java
  5. +76
    -0
      app/src/main/java/com/qhclh/ytzh/index/fumudai/ThreeTypeAdapter.java
  6. +33
    -0
      app/src/main/res/layout/item_threetype.xml

+ 61
- 0
app/src/main/java/com/qhclh/ytzh/bean/ThreeTypeBean.java View File

@ -0,0 +1,61 @@
package com.qhclh.ytzh.bean;
/**
* Created by 青花瓷 on 2018/3/9.
*/
public class ThreeTypeBean {
private long yangzhichangid;
private String yangzhichangname;
private String firstitem;
private String seconditem;
public ThreeTypeBean(long yangzhichangid, String yangzhichangname, String firstitem, String seconditem) {
this.yangzhichangid = yangzhichangid;
this.yangzhichangname = yangzhichangname;
this.firstitem = firstitem;
this.seconditem = seconditem;
}
public long getYangzhichangid() {
return yangzhichangid;
}
public void setYangzhichangid(long yangzhichangid) {
this.yangzhichangid = yangzhichangid;
}
public String getYangzhichangname() {
return yangzhichangname;
}
public void setYangzhichangname(String yangzhichangname) {
this.yangzhichangname = yangzhichangname;
}
public String getFirstitem() {
return firstitem;
}
public void setFirstitem(String firstitem) {
this.firstitem = firstitem;
}
public String getSeconditem() {
return seconditem;
}
public void setSeconditem(String seconditem) {
this.seconditem = seconditem;
}
@Override
public String toString() {
return "ThreeTypeBean{" +
"yangzhichangid=" + yangzhichangid +
", yangzhichangname='" + yangzhichangname + '\'' +
", firstitem='" + firstitem + '\'' +
", seconditem='" + seconditem + '\'' +
'}';
}
}

+ 9
- 0
app/src/main/java/com/qhclh/ytzh/home/RpcUrl.java View File

@ -100,6 +100,15 @@ public class RpcUrl {
public static String HouseTypeCount ="/MainSystem/B3_ZhongHui/Rpcs/HatchReportRpc/HouseTypeCount"; public static String HouseTypeCount ="/MainSystem/B3_ZhongHui/Rpcs/HatchReportRpc/HouseTypeCount";
public static String HouseTypeCount_fanhui ="/MainSystem/B3_ZhongHui/Rpcs/HouseStatusCountInfo"; public static String HouseTypeCount_fanhui ="/MainSystem/B3_ZhongHui/Rpcs/HouseStatusCountInfo";
public static String BreedFactoryCountView0 ="/MainSystem/B3_ZhongHui/Rpcs/HatchReportRpc/BreedFactoryCountView0";
public static String BreedFactoryCountView0_fanhui ="/MainSystem/B3_ZhongHui/Rpcs/HouseStatusBreedFactoryCountView0Info";
public static String BreedFactoryCountView1 ="/MainSystem/B3_ZhongHui/Rpcs/HatchReportRpc/BreedFactoryCountView1";
public static String BreedFactoryCountView1_fanhui ="/MainSystem/B3_ZhongHui/Rpcs/HouseStatusBreedFactoryCountView1Info";
public static String BreedFactoryCountView2 ="/MainSystem/B3_ZhongHui/Rpcs/HatchReportRpc/BreedFactoryCountView2";
public static String BreedFactoryCountView2_fanhui ="/MainSystem/B3_ZhongHui/Rpcs/HouseStatusBreedFactoryCountView2Info";
} }

+ 0
- 1
app/src/main/java/com/qhclh/ytzh/index/fumudai/FumudaiFragment.java View File

@ -97,7 +97,6 @@ public class FumudaiFragment extends BaseFragment {
List<RpcObject> rpcList; List<RpcObject> rpcList;
@Override @Override
protected void successUI() { protected void successUI() {
System.out.println("aaa++++++"+rpcList);
fumudaiBeenList.clear(); fumudaiBeenList.clear();
for (int i=0;i<rpcList.size();i++) { for (int i=0;i<rpcList.size();i++) {
fumudaiBeenList.add(new FumudaiBean(rpcList.get(i).getInt("Status"), rpcList.get(i).getInt("Number"))); fumudaiBeenList.add(new FumudaiBean(rpcList.get(i).getInt("Status"), rpcList.get(i).getInt("Number")));


+ 36
- 2
app/src/main/java/com/qhclh/ytzh/index/fumudai/ThreeTypeActivity.java View File

@ -1,13 +1,29 @@
package com.qhclh.ytzh.index.fumudai; package com.qhclh.ytzh.index.fumudai;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import com.qhclh.ytzh.R; import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseActivity; import com.qhclh.ytzh.base.BaseActivity;
import butterknife.BindView;
/** /**
* Created by 青花瓷 on 2018/3/9. * Created by 青花瓷 on 2018/3/9.
*/ */
public class ThreeTypeActivity extends BaseActivity { public class ThreeTypeActivity extends BaseActivity {
@BindView(R.id.toolbar)
Toolbar mToolbar;
@BindView(R.id.tv_toolbar_title)
TextView tv_toolbar_title;
@BindView(R.id.lv_threetype)
ListView lv_threetype;
private long status;
@Override @Override
protected int setLayoutId() { protected int setLayoutId() {
return R.layout.act_threetype; return R.layout.act_threetype;
@ -15,16 +31,34 @@ public class ThreeTypeActivity extends BaseActivity {
@Override @Override
protected void initView() { protected void initView() {
initToolbar(mToolbar, "", new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
} }
@Override @Override
protected void initData() { protected void initData() {
status = getIntent().getLongExtra("status",-1);
if (status ==0){
tv_toolbar_title.setText("空栏");
}else if (status == 1){
tv_toolbar_title.setText("育雏育成期");
}else if (status == 2){
tv_toolbar_title.setText("产蛋期");
}
} }
@Override @Override
protected void initOper() { protected void initOper() {
} }
@Override
protected void onResume() {
super.onResume();
}
} }

+ 76
- 0
app/src/main/java/com/qhclh/ytzh/index/fumudai/ThreeTypeAdapter.java View File

@ -0,0 +1,76 @@
package com.qhclh.ytzh.index.fumudai;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.qhclh.ytzh.R;
import com.qhclh.ytzh.bean.ThreeTypeBean;
import java.util.List;
/**
* Created by 青花瓷 on 2018/3/9.
*/
public class ThreeTypeAdapter extends BaseAdapter {
private Context context;
private List<ThreeTypeBean> list;
private LayoutInflater layoutInflater;
public ThreeTypeAdapter(Context context, List<ThreeTypeBean> list) {
this.context = context;
this.list = list;
layoutInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return list.get(i);
}
@Override
public long getItemId(int i) {
return list.get(i).getYangzhichangid();
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
ViewHolder viewHolder;
ThreeTypeBean message = list.get(i);
if (view == null){
view = layoutInflater.inflate(R.layout.item_threetype,viewGroup,false);
viewHolder = new ViewHolder();
viewHolder.item_three_yangzhichang = view.findViewById(R.id.item_three_yangzhichang);
viewHolder.item_three_item1 = view.findViewById(R.id.item_three_item1);
viewHolder.item_three_item2 = view.findViewById(R.id.item_three_item2);
view.setTag(viewHolder);
}else {
viewHolder = (ViewHolder) view.getTag();
}
viewHolder.item_three_yangzhichang.setText(message.getYangzhichangname());
viewHolder.item_three_item1.setText(message.getFirstitem());
viewHolder.item_three_item2.setText(message.getSeconditem());
return view;
}
private class ViewHolder{
private TextView item_three_yangzhichang;
private TextView item_three_item1;
private TextView item_three_item2;
}
}

+ 33
- 0
app/src/main/res/layout/item_threetype.xml View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white"
android:padding="@dimen/dp_10">
<TextView
android:id="@+id/item_three_yangzhichang"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal">
<TextView
android:id="@+id/item_three_item1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/item_three_item2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>

Loading…
Cancel
Save