ورود

View Full Version : مشکل spinner من در listview



capitan_nemesis
پنج شنبه 05 مهر 1397, 11:21 صبح
با سلام
http://uupload.ir/files/rla_untitled_thumb.png (http://uupload.ir/view/rla_untitled.png)
کسی مشکل اینو میدونه
من تو یه اکتیویتی بانک کل بانک رو ذخیره میکنم و در اکتیویتی اشخاص نام بانک روی spinner نمایش داده میشه و حالا روی listView اشخاص قراره نام بانک نمایش داده میشه ولی نمیدونم چطوری
این عکس رو دادم ببینید برای Adapter هستش
چکار باید بکنم؟؟؟؟
ممنون
---------------
خیلی نیازه ممنون میشم یکی این مشکل منو درست کنه
---------------
اینم کدش

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.List;
import ir.linux.hoomanaccounting.R;
import ir.linux.hoomanaccounting.models.PersonModel;

public class PersonAdap extends ArrayAdapter<PersonModel>
{
private Context mc;
private int rc;

public PersonAdap (@NonNull Context context, int resource, @NonNull List<PersonModel> objects)
{
super(context, resource, objects);
mc = context;
rc = resource;
}

@SuppressLint("NewApi")
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
{
String name = getItem(position).getName();
String family = getItem(position).getFamily();
String bank = getItem(position).getBank();
String office = getItem(position).getOffice();


LayoutInflater inflater = LayoutInflater.from(mc);
convertView = inflater.inflate(rc,parent,false);

TextView nameText = convertView.findViewById(R.id.person_name_raw);
TextView familyText = convertView.findViewById(R.id.person_famiy_raw);
Spinner bankText = convertView.findViewById(R.id.person_bank_raw);
TextView officeText = convertView.findViewById(R.id.person_office_raw);

nameText.setText(name);
familyText.setText(family);
bankText.setDropDownWidth(Integer.parseInt(bank));
officeText.setText(office);

return convertView;
}

farhad_shiri_ex
شنبه 07 مهر 1397, 08:27 صبح
با سلام
http://uupload.ir/files/rla_untitled_thumb.png (http://uupload.ir/view/rla_untitled.png)
کسی مشکل اینو میدونه
من تو یه اکتیویتی بانک کل بانک رو ذخیره میکنم و در اکتیویتی اشخاص نام بانک روی spinner نمایش داده میشه و حالا روی listView اشخاص قراره نام بانک نمایش داده میشه ولی نمیدونم چطوری
این عکس رو دادم ببینید برای Adapter هستش
چکار باید بکنم؟؟؟؟
ممنون
---------------
خیلی نیازه ممنون میشم یکی این مشکل منو درست کنه
---------------
اینم کدش

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.List;
import ir.linux.hoomanaccounting.R;
import ir.linux.hoomanaccounting.models.PersonModel;

public class PersonAdap extends ArrayAdapter<PersonModel>
{
private Context mc;
private int rc;

public PersonAdap (@NonNull Context context, int resource, @NonNull List<PersonModel> objects)
{
super(context, resource, objects);
mc = context;
rc = resource;
}

@SuppressLint("NewApi")
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
{
String name = getItem(position).getName();
String family = getItem(position).getFamily();
String bank = getItem(position).getBank();
String office = getItem(position).getOffice();


LayoutInflater inflater = LayoutInflater.from(mc);
convertView = inflater.inflate(rc,parent,false);

TextView nameText = convertView.findViewById(R.id.person_name_raw);
TextView familyText = convertView.findViewById(R.id.person_famiy_raw);
Spinner bankText = convertView.findViewById(R.id.person_bank_raw);
TextView officeText = convertView.findViewById(R.id.person_office_raw);

nameText.setText(name);
familyText.setText(family);
bankText.setDropDownWidth(Integer.parseInt(bank));
officeText.setText(office);

return convertView;
}



دوست عزیز کدی که گذاشتید را توی تگ [java] قرار بدید. تا قابل استفاده باشه.

capitan_nemesis
شنبه 07 مهر 1397, 13:17 عصر
دوست عزیز کدی که گذاشتید را توی تگ [java] قرار بدید. تا قابل استفاده باشه.

تو تگ جاوا هستش آپلود میکنم تو تگ نمیزارم

Nevercom
سه شنبه 10 مهر 1397, 13:11 عصر
سوالتون برا من واضح نیست، شما تو آبجکت PersonModel فیلدی تحت عنوان bank دارید که تو لیست‌ویو هم ازش استفاده شده.
چیزی که متوجه نشدم اینه که ارتباط Spinner با ListView چی هست ؟

می‌خواید اگه تو اسپینر یه بانک خاص انتخاب شد، تو لیست ویو کاربرانی که بانکشون همونه فقط نمایش داده بشه ؟

نیازه توضیح بیشتری بدید.

ضمن اینکه برای اینکه تگ های HTML به کدی که تو فروم میزارید اضافه نشه، بعد اینکه کدتون رو تو تگ CODE یا JAVA گذاشتید، تو ادیتور دومین گزینه بالا سمت راست (Remove Format) رو بزنید