آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

لیست ویو تودرتو (Nested ListView)

haftasia  10 سال پیش  9 سال پیش
0 0

من دنبال یک لیست ویو میگردم تا محتوا منو به صورت درختی نمایش بده. این لیست حداقل تا چهار سطح قراره باز بشه

کسی از دوستان تا بحال لایبرری چنین لیست ویو یی رو دیده معرفی کنه .

تشکر

0 0
سلام فکر کنم ExpandableListView کارت رو راه بندازه (10 سال پیش)
0 0
تا چهار سطح داخلی بتونم دسترسی داشته باشم!! Expandable Listview سطح دسترسیش یک سطح هست!!! من نظرم این بود از داخل سلول های ExpandableListview هم باز دوباره Expandable استفاده کنم !!! اما اصولی نیست و خیلی پیچیده ست!! هنوز منتظر راهنمایهاتون هستم (10 سال پیش)
 برای این سوال 2 پاسخ وجود دارد.
پاسخ به سوال 
مهدی  10 سال پیش
0 0

درود

ببین این بدردت میخوره لینک

0 0
چرا lst.setSelection() کار نمیکنه؟ (9 سال پیش)
پاسخ به سوال 
haftasia  10 سال پیش
0 0

میخوام از ExpandableListView به صورت تو در تو استفاده کنم یعنی چیلد های لیست هر کدوم یک Expandable باشن

در برنامه فقط تونستم یک لیست رو استفاده کنم

public class MainActivity extends AppCompatActivity{

DrawerLayout mDrawerlayout;
ExpandableListView mDrawerList_Left,mDrawerList_Right;
ImageButton ImgBtnRight , ImgBtnLeft;
RecyclerView Recycler;

private ExpandListAdapter ExpAdapter;
private ArrayList<Group> ExpListItems;
private ParentChildAdapter Adp;

private ArrayList<SuperGroup> sExpListItems;

Context context;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    context =MainActivity.this;



    mDrawerList_Left=(ExpandableListView)findViewById(R.id.drawer_list_left);
    mDrawerList_Right=(ExpandableListView)findViewById(R.id.drawer_list_right);


    ExpListItems = SetStandardGroups();
    ExpAdapter = new ExpandListAdapter(context,ExpListItems);
    mDrawerList_Left.setAdapter(ExpAdapter);


}

public ArrayList<Group> SetStandardGroups() {

    String group_names[] = { "GROUP A", "GROUP B", "GROUP C", "GROUP D",
            "GROUP E", "GROUP F", "GROUP G", "GROUP H" };

    String country_names[] = { "Brazil", "Mexico", "Croatia", "Cameroon",
            "Netherlands", "chile", "Spain", "Australia", "Colombia",
            "Greece", "Ivory Coast", "Japan", "Costa Rica", "Uruguay",
            "Italy", "England", "France", "Switzerland", "Ecuador",
            "Honduras", "Agrentina", "Nigeria", "Bosnia and Herzegovina",
            "Iran", "Germany", "United States", "Portugal", "Ghana",
            "Belgium", "Algeria", "Russia", "Korea Republic" };

    int Images[] = { R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic, R.drawable.myic,
            R.drawable.myic, R.drawable.myic, R.drawable.myic,
            R.drawable.myic };

    ArrayList<Group> list = new ArrayList<Group>();

    ArrayList<Child> ch_list;

    int size = 4;
    int j = 0;

    for (String group_name : group_names) {
        Group gru = new Group();
        gru.setName(group_name);

        ch_list = new ArrayList<Child>();
        for (; j < size; j++) {
            Child ch = new Child();
            ch.setName(country_names[j]);
            ch.setImage(Images[j]);
            ch_list.add(ch);
        }
        gru.setItems(ch_list);
        list.add(gru);

        size = size + 4;
    }

    return list;
}

}

و این ادپترش هست

public class ExpandListAdapter extends BaseExpandableListAdapter {
private Context context; private ArrayList<Group> groups; public ExpandListAdapter(Context context, ArrayList<Group> groups) { this.context = context; this.groups = groups; } @Override public Object getChild(int groupPosition, int childPosition) { ArrayList<Child> chList = groups.get(groupPosition).getItems(); return chList.get(childPosition); } @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { Child child = (Child) getChild(groupPosition, childPosition); if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) context .getSystemService(context.LAYOUT_INFLATER_SERVICE); convertView = infalInflater.inflate(R.layout.child_item, null); } TextView tv = (TextView) convertView.findViewById(R.id.country_name); ImageView iv = (ImageView) convertView.findViewById(R.id.flag); tv.setText(child.getName().toString()); iv.setImageResource(child.getImage()); return convertView; } @Override public int getChildrenCount(int groupPosition) { ArrayList<Child> chList = groups.get(groupPosition).getItems(); return chList.size(); } @Override public Object getGroup(int groupPosition) { return groups.get(groupPosition); } @Override public int getGroupCount() { return groups.size(); } @Override public long getGroupId(int groupPosition) { return groupPosition; } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { Group group = (Group) getGroup(groupPosition); if (convertView == null) { LayoutInflater inf = (LayoutInflater) context .getSystemService(context.LAYOUT_INFLATER_SERVICE); convertView = inf.inflate(R.layout.group_item, null); } TextView tv = (TextView) convertView.findViewById(R.id.group_name); tv.setText(group.getName()); return convertView; } @Override public boolean hasStableIds() { return true; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; }

}


پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .