1. AC Question's Avatar
    CHILD ACTIVITY :`

    <GridView
    android:id="@+id/twoflagsview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnWidth="100dp"
    android:drawSelectorOnTop="true"
    android:gravity="center"
    android:numColumns="3"

    android:stretchMode="columnWidth"
    android:verticalSpacing="0dp"
    android:focusable="true"
    android:clickable="true">
    </GridView>
    Expandable List view adapter :`

    public class Myexpandablelistadapter extends BaseExpandableListAdapter
    {
    Context context;
    List<String> langs;
    Map<String, List<String>> topics;
    GridView one_flag_gridview;

    One_flag_gridadapter one_flag_griddapter;
    public int[] mBackgroundResources ={

    R.drawable.america_flag,
    R.drawable.argentina_flag,
    R.drawable.armenia_flag,
    R.drawable.iplchenai_super_kings,
    R.drawable.ipldehli_devils,
    R.drawable.iplkings_xi_punjab,
    };

    Myexpandablelistadapter( Context context,List<String> langs, Map<String, List<String>> topics)
    {
    this.context=context;
    this.langs=langs;
    this.topics=topics;
    }

    @override
    public int getGroupCount() {
    return langs.size();
    }

    @override
    public int getChildrenCount(int i) {
    return topics.get(langs.get(i)).size();
    }

    @override
    public Object getGroup(int i) {
    return langs.get(i);
    }

    @override
    public Object getChild(int i, int i1) {
    return topics.get(langs.get(i)).get(i1);
    }

    @override
    public long getGroupId(int i) {
    return i;
    }

    @override
    public long getChildId(int i, int i1) {
    return i1;
    }

    @override
    public boolean hasStableIds() {
    return true;
    }

    @override
    public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {

    String langs=(String)getGroup(i);
    if(view==null)
    {
    LayoutInflater layoutInflater=(LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
    view=layoutInflater.inflate(R.layout.list_parent,null);
    }
    TextView textView=(TextView)view.findViewById(R.id.parent_litview);
    textView.setText(langs);

    return view;
    }

    @override
    public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {
    ViewGroup item = getViewGroupChild(view, viewGroup);

    one_flag_gridview = (GridView) item.findViewById(R.id.twoflagsview);

    one_flag_griddapter = new One_flag_gridadapter(context, R.layout.itemlist, getData1(),1);
    one_flag_gridview.setAdapter(one_flag_griddapter);

    return item;
    }

    @override
    public boolean isChildSelectable(int i, int i1) {
    return true;
    }

    private ArrayList<ImageItem> getData1() {
    final ArrayList<ImageItem> imageItems = new ArrayList<>();

    for (int i = 0; i < mBackgroundResources.length; i++) {

    imageItems.add(new ImageItem(mBackgroundResources[i]));
    }
    return imageItems;
    }

    private ViewGroup getViewGroupChild(View convertView, ViewGroup parent)
    {
    // The parent will be our ListView from the ListActivity
    if (convertView instanceof ViewGroup)
    {
    return (ViewGroup) convertView;
    }
    Context context = parent.getContext();
    LayoutInflater inflater = LayoutInflater.from(context);
    ViewGroup item = (ViewGroup) inflater.inflate(R.layout.list_childe, null);
    return item;
    }

    }
    Grid view adapter here:

    public class One_flag_gridadapter extends ArrayAdapter { private Context context;
    private int layoutResourceId;
    private ArrayList data = new ArrayList();
    public int[] mBackgroundResources ={

    R.drawable.america_flag,
    R.drawable.argentina_flag,
    R.drawable.armenia_flag,
    R.drawable.iplchenai_super_kings,
    R.drawable.ipldehli_devils,
    R.drawable.iplkings_xi_punjab,
    };

    InputStream is;
    int i11;

    public One_flag_gridadapter(Context context, int layoutResourceId, ArrayList data,int i) {
    super(context, layoutResourceId, data);
    this.layoutResourceId = layoutResourceId;
    this.context = context;
    i11=i;

    }

    @override
    public int getCount() {
    return mBackgroundResources.length;
    }

    @override
    public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    ViewHolder holder = null;

    if (row == null) {
    LayoutInflater inflater = ((Activity) context).getLayoutInflater();
    row = inflater.inflate(layoutResourceId, parent, false);
    holder = new ViewHolder();

    holder.image = (ImageView) row.findViewById(R.id.image);

    row.setTag(holder);
    } else {
    holder = (ViewHolder) row.getTag();
    }

    is = context.getResources().openRawResource(mBackgroundResources[position]);

    Bitmap mThumbnail = scaleBitmap(BitmapFactory.decodeStream(is));
    holder.image.setImageBitmap(mThumbnail);

    return row;
    }

    static class ViewHolder {
    ImageView image;
    TextView text;
    }

    private static Bitmap scaleBitmap2(Bitmap source) {
    int maxSize = source.getWidth() > source.getHeight() ? source.getWidth() : source.getHeight();
    return Bitmap.createScaledBitmap(source, source.getWidth() * 120 / maxSize, source
    .getHeight() * 115 / maxSize, true);
    }

    private static Bitmap scaleBitmap(Bitmap source) {
    int maxSize = source.getWidth() > source.getHeight() ? source.getWidth() : source.getHeight();
    return Bitmap.createScaledBitmap(source, source.getWidth() * 120 / maxSize, source
    .getHeight() * 96 / maxSize, true);
    }
    }
    can anyone help ?
    03-31-2017 06:29 AM

Similar Threads

  1. 24 Hours with the LG G6
    By jimbo1mcm in forum LG G6
    Replies: 27
    Last Post: 04-01-2017, 01:50 PM
  2. Replies: 1
    Last Post: 03-31-2017, 07:03 AM
  3. Replies: 1
    Last Post: 03-31-2017, 05:45 AM
  4. Replies: 1
    Last Post: 03-31-2017, 04:36 AM
  5. Android Lollipop Bluetooth Profiles not enabled in UI with Bluez Stack
    By anjisagar in forum Legacy Android & Other OS's
    Replies: 0
    Last Post: 03-31-2017, 04:24 AM
LINK TO POST COPIED TO CLIPBOARD