Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何获取项目的位置';什么是儿童观?_Java_Android_Json - Fatal编程技术网

Java 如何获取项目的位置';什么是儿童观?

Java 如何获取项目的位置';什么是儿童观?,java,android,json,Java,Android,Json,在列表视图中,我以编程方式创建了图像视图,并将其添加到ListView项内部的线性布局中。然后如何得到图像的位置 下面我添加了getView()方法。我在“String[]childDocument”中得到多个图像。使用for loop I从字符串[]和外接程序线性布局中提取图像 @NonNull @Override public View getView(final int position, View convertView, @NonNull ViewGroup parent) {

在列表视图中,我以编程方式创建了图像视图,并将其添加到ListView项内部的线性布局中。然后如何得到图像的位置

下面我添加了getView()方法。我在“String[]childDocument”中得到多个图像。使用for loop I从字符串[]和外接程序线性布局中提取图像

    @NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    final ApproveReimbBin item = getItem(position);
    FoldingCell cell = (FoldingCell) convertView;
    final ViewHolder viewHolder;

    String date = item.getStr_startDate();
    String[] splitDate = date.split("To");

    String profileName = item.getStr_name();
    String profileEmpId = item.getStr_empId();
    String profileType = item.getStr_type();
    String profileAmount = item.getStr_amount();
    final String[] childDocument = item.getStr_documents();

    if (cell == null) {
        viewHolder = new ViewHolder();
        LayoutInflater vi = LayoutInflater.from(getContext());
        cell = (FoldingCell) vi.inflate(R.layout.adapter_approvereimburs, parent, false);

        // binding view parts to view holder
        viewHolder.imag_listProfileImage = cell.findViewById(R.id.list_image);
        viewHolder.txt_listName = cell.findViewById(R.id.list_profileName);
        viewHolder.txt_listEmpId = cell.findViewById(R.id.list_profileEmpId);
        viewHolder.txt_listType = cell.findViewById(R.id.list_profileType);

        viewHolder.image_childProfileImage = cell.findViewById(R.id.child_profile_img);
        viewHolder.txt_name = cell.findViewById(R.id.txt_profile_name);
        viewHolder.txt_empId = cell.findViewById(R.id.txt_profile_id);
        viewHolder.txt_type = cell.findViewById(R.id.txt_profile_type);

        viewHolder.txt_frmDate = cell.findViewById(R.id.txt_from_date);
        viewHolder.txt_toDate = cell.findViewById(R.id.txt_to_date);
        viewHolder.txt_amount = cell.findViewById(R.id.txt_amount);
        viewHolder.btn_reject = cell.findViewById(R.id.btn_reject);
        viewHolder.btn_approve = cell.findViewById(R.id.btn_approve);
        viewHolder.linearLayout = cell.findViewById(R.id.linearLayout_Image);

        cell.setTag(viewHolder);
    } else {
        if (unfoldedIndexes.contains(position)) {
            cell.unfold(true);
            Log.e("suraj", "unfold call");
        } else {
            cell.fold(true);
            Log.e("suraj", "fold call");
        }
        viewHolder = (ViewHolder) cell.getTag();
    }

    if (null == item)
        return cell;


    String ImageUrl = ServerUrls.Web.IMAGE_URL + profileEmpId.trim() + ".jpg";

    ImageView image;


    if (viewHolder.linearLayout.getChildCount() > 0) {
        viewHolder.linearLayout.removeAllViews();
    }
    for (int i = 0; i < childDocument.length; i++) {

        String doc = childDocument[i].replace("~", "");
        doc = doc.replace("\\", "/");
        doc = doc.replace(",", "");

        image = new ImageView(mContext);
        image.setLayoutParams(new android.view.ViewGroup.LayoutParams(100, 100));
        image.setMaxHeight(100);
        image.setMaxWidth(100);

        Log.e("surajjj", "for loop use " + imageDocument.trim() + doc);

        Picasso.with(mContext)
                .load(imageDocument.trim() + doc)
                .error(R.drawable.doc_img)
                .into(image);

        viewHolder.linearLayout.addView(image);
        int lent = childDocument.length;
        Log.e("surajj", "docu " + imageDocument.trim() + doc + " position " + i + " lenth " + lent);
    }


    viewHolder.linearLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int sr = viewHolder.linearLayout.indexOfChild(view);
            Toast.makeText(mContext, "Postition is "+ sr, Toast.LENGTH_SHORT).show();
        }
    });

    viewHolder.linearLayout.getChildAt(position).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            Toast.makeText(mContext, childDocument.toString(), Toast.LENGTH_SHORT).show();
        }
    });

    Picasso.with(mContext)
            .load(ImageUrl.trim())
            .error(R.drawable.ic_user)
            .into(viewHolder.imag_listProfileImage);

    Picasso.with(mContext)
            .load(ImageUrl.trim())
            .error(R.drawable.ic_user)
            .into(viewHolder.image_childProfileImage);


    if (profileName != null || !profileName.equals(" ")) {
        viewHolder.txt_listName.setText(profileName);
        viewHolder.txt_name.setText(profileName);
    }
    if (profileEmpId != null || !profileEmpId.equals(" ")) {
        viewHolder.txt_listEmpId.setText(profileEmpId);
        viewHolder.txt_empId.setText(profileEmpId);
    }
    if (profileType != null || !profileType.equals(" ")) {
        viewHolder.txt_listType.setText(profileType);
        viewHolder.txt_type.setText(profileType);
    }
    if (profileAmount != null || !profileAmount.equals(" ")) {
        viewHolder.txt_amount.setText(profileAmount);
    }

    if (splitDate != null || !splitDate.equals(" ")) {

        if (splitDate.length == 2) {
            Log.d("suraj1", "fromDate " + splitDate[0] + " toDate " + splitDate[1]);

            viewHolder.txt_frmDate.setText(splitDate[0]);
            viewHolder.txt_toDate.setText(splitDate[1]);
        } else {
            Log.d("suraj1", "onlyfromDate " + splitDate[0]);
            viewHolder.txt_frmDate.setText(splitDate[0]);
        }
    }

    viewHolder.btn_approve.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            requestId = item.getStr_requestId();
            reimbursmentId = item.getStr_reimbursementid();
            action = "Approved";
            Methods.showProgressDialog(mContext);
            unfoldedIndexes.clear();
            new asyncSendRequest().execute();
        }
    });

    viewHolder.btn_reject.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            requestId = item.getStr_requestId();
            reimbursmentId = item.getStr_reimbursementid();
            action = "Rejected";
            Methods.showProgressDialog(mContext);
            unfoldedIndexes.clear();
            new asyncSendRequest().execute();
        }
    });

    return cell;
}
@NonNull
@凌驾
公共视图getView(最终整型位置,视图转换视图,@NonNull视图组父级){
最终审批人eimbbin item=getItem(position);
FoldingCell=(FoldingCell)convertView;
最终持票人;
字符串日期=item.getStr_startDate();
字符串[]splitDate=date.split(“To”);
String profileName=item.getStr_name();
String profileEmpId=item.getStr_empId();
String profileType=item.getStr_type();
String profileAmount=item.getStr_amount();
最终字符串[]childDocument=item.getStr_documents();
if(单元格==null){
viewHolder=新的viewHolder();
LayoutInflater vi=LayoutInflater.from(getContext());
单元格=(折叠单元格)vi.充气(R.layout.adapter\u\burs,父项,false);
//将视图零件绑定到视图保持架
viewHolder.imag\u listProfileImage=cell.findviewbyd(R.id.list\u image);
viewHolder.txt_listName=cell.findviewbyd(R.id.list_profileName);
viewHolder.txt_listEmpId=cell.findviewbyd(R.id.list_profileEmpId);
viewHolder.txt_listType=cell.findViewById(R.id.list_profileType);
viewHolder.image\u childProfileImage=cell.findviewbyd(R.id.child\u profile\u img);
viewHolder.txt\u name=cell.findviewbyd(R.id.txt\u profile\u name);
viewHolder.txt_empId=cell.findviewbyd(R.id.txt_profile_id);
viewHolder.txt\u type=cell.findviewbyd(R.id.txt\u profile\u type);
viewHolder.txt\u frmDate=cell.findviewbyd(R.id.txt\u自\u日期起);
viewHolder.txt_toDate=cell.findviewbyd(R.id.txt_to_date);
viewHolder.txt\u amount=cell.findviewbyd(R.id.txt\u amount);
viewHolder.btn_拒绝=cell.findviewbyd(R.id.btn_拒绝);
viewHolder.btn\u approve=cell.findviewbyd(R.id.btn\u approve);
viewHolder.linearLayout=cell.findviewbyd(R.id.linearLayout\u图像);
cell.setTag(viewHolder);
}否则{
if(展开索引包含(位置)){
单元展开(真);
Log.e(“suraj”、“展开调用”);
}否则{
细胞折叠(真);
Log.e(“suraj”,“fold call”);
}
viewHolder=(viewHolder)cell.getTag();
}
if(null==项)
返回单元;
字符串ImageUrl=serverurl.Web.IMAGE_URL+profileEmpId.trim()+“.jpg”;
图像视图图像;
如果(viewHolder.linearLayout.getChildCount()>0){
viewHolder.linearLayout.removeAllViews();
}
for(int i=0;i