コード例 #1
0
 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
ファイル: DebtorsFragment.java プロジェクト: crghostapps/Myex
  @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;
  }
コード例 #3
0
ファイル: DebtorsFragment.java プロジェクト: crghostapps/Myex
  /**
   * The default content for this Fragment has a TextView that is shown when the list is empty. If
   * you would like to change the text, call this method to supply the text it should use.
   */
  public void setEmptyText(CharSequence emptyText) {
    View emptyView = mListView.getEmptyView();

    if (emptyView instanceof TextView) {
      ((TextView) emptyView).setText(emptyText);
    }
  }
コード例 #4
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ButterKnife.inject(this, view);

    ((AdapterView<ListAdapter>) listView).setAdapter(adapter);
    listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    search.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s.toString());
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
コード例 #5
0
 @SuppressWarnings("ConstantConditions")
 public static void setEventListener(
     Object handler,
     ViewFinder finder,
     DoubleKeyValueMap<Object, Annotation, Method> value_annotation_method_map) {
   for (Object value : value_annotation_method_map.getFirstKeys()) {
     ConcurrentHashMap<Annotation, Method> annotation_method_map =
         value_annotation_method_map.get(value);
     for (Annotation annotation : annotation_method_map.keySet()) {
       try {
         Method method = annotation_method_map.get(annotation);
         if (annotation.annotationType().equals(OnClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnLongClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnLongClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnFocusChange.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnFocusChangeListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnKey.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnKeyListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnTouch.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.setOnTouchListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnItemClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((AdapterView<?>) view)
               .setOnItemClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnItemLongClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((AdapterView<?>) view)
               .setOnItemLongClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnChildClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((ExpandableListView) view)
               .setOnChildClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnGroupClick.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((ExpandableListView) view)
               .setOnGroupClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnGroupCollapse.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((ExpandableListView) view)
               .setOnGroupCollapseListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnGroupExpand.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((ExpandableListView) view)
               .setOnGroupExpandListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnCheckedChange.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           if (view instanceof RadioGroup) {
             ((RadioGroup) view)
                 .setOnCheckedChangeListener(new ViewCommonEventListener(handler, method));
           } else if (view instanceof CompoundButton) {
             ((CompoundButton) view)
                 .setOnCheckedChangeListener(new ViewCommonEventListener(handler, method));
           }
         } else if (annotation.annotationType().equals(OnPreferenceClick.class)) {
           Preference preference = finder.findPreference(value.toString());
           if (preference == null) break;
           preference.setOnPreferenceClickListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnPreferenceChange.class)) {
           Preference preference = finder.findPreference(value.toString());
           if (preference == null) break;
           preference.setOnPreferenceChangeListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnTabChange.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           ((TabHost) view).setOnTabChangedListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnScrollChanged.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           view.getViewTreeObserver()
               .addOnScrollChangedListener(new ViewCommonEventListener(handler, method));
         } else if (annotation.annotationType().equals(OnScrollStateChanged.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           Method method0 = null, method1 = null;
           ConcurrentHashMap<Annotation, Method> a_m_map = value_annotation_method_map.get(value);
           for (Annotation a : a_m_map.keySet()) {
             if (a.annotationType().equals(OnScrollStateChanged.class)) {
               method0 = a_m_map.get(a);
             } else if (a.annotationType().equals(OnScroll.class)) {
               method1 = a_m_map.get(a);
             }
           }
           ((AbsListView) view)
               .setOnScrollListener(new ViewCommonEventListener(handler, method0, method1));
         } else if (annotation.annotationType().equals(OnItemSelected.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           Method method0 = null, method1 = null;
           ConcurrentHashMap<Annotation, Method> a_m_map = value_annotation_method_map.get(value);
           for (Annotation a : a_m_map.keySet()) {
             if (a.annotationType().equals(OnItemSelected.class)) {
               method0 = a_m_map.get(a);
             } else if (a.annotationType().equals(OnNothingSelected.class)) {
               method1 = a_m_map.get(a);
             }
           }
           ((AdapterView<?>) view)
               .setOnItemSelectedListener(new ViewCommonEventListener(handler, method0, method1));
         } else if (annotation.annotationType().equals(OnProgressChanged.class)) {
           View view = finder.findViewById((Integer) value);
           if (view == null) break;
           Method method0 = null, method1 = null, method2 = null;
           ConcurrentHashMap<Annotation, Method> a_m_map = value_annotation_method_map.get(value);
           for (Annotation a : a_m_map.keySet()) {
             if (a.annotationType().equals(OnProgressChanged.class)) {
               method0 = a_m_map.get(a);
             } else if (a.annotationType().equals(OnStartTrackingTouch.class)) {
               method1 = a_m_map.get(a);
             } else if (a.annotationType().equals(OnStopTrackingTouch.class)) {
               method2 = a_m_map.get(a);
             }
           }
           ((SeekBar) view)
               .setOnSeekBarChangeListener(
                   new ViewCommonEventListener(handler, method0, method1, method2));
         }
       } catch (Throwable e) {
         LogUtils.e(e.getMessage(), e);
       }
     }
   }
 }