public DropdownContainer(
     Context context,
     int layout_id,
     Drawable background,
     DropdownAdapter adapter,
     OnItemClickListener listener) {
   super(context);
   int m = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
   AbsListView content = (AbsListView) LayoutInflater.from(context).inflate(layout_id, null);
   if (content instanceof ListView) {
     ((ListView) content).setAdapter((BaseAdapter) adapter);
   } else if (content instanceof GridView) {
     ((GridView) content).setAdapter((BaseAdapter) adapter);
   }
   content.setOnItemClickListener(listener);
   content.measure(m, m);
   if (adapter.getRows() > adapter.getWrapRow()) {
     init(
         content,
         LayoutParams.WRAP_CONTENT,
         content.getMeasuredHeight() * adapter.getWrapRow(),
         R.style.drop_down_anim,
         background);
   } else {
     init(
         content,
         LayoutParams.WRAP_CONTENT,
         LayoutParams.WRAP_CONTENT,
         R.style.drop_down_anim,
         background);
   }
 }
Пример #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_debtors, container, false);

    // Set the adapter
    mListView = (AbsListView) view.findViewById(android.R.id.list);
    ((AdapterView<ListAdapter>) mListView).setAdapter(mAdapter);

    // Set OnItemClickListener so we can be notified on item clicks
    mListView.setOnItemClickListener(this);
    mListView.setOnItemLongClickListener(this);
    mListView.setEmptyView(view.findViewById(android.R.id.empty));

    return view;
  }