Пример #1
0
  /**
   * Method that creates a cursor from the calllog and chooses the Number, Type and Date as columns
   * Custom SimpleCursorAdapter is used for the list
   */
  private void getCallLog() {
    cursor = managedQuery(CallLog.Calls.CONTENT_URI, null, null, null, null);

    String[] fromColumns = {CallLog.Calls.NUMBER, CallLog.Calls.TYPE, CallLog.Calls.DATE};
    int[] toColumns = {R.id.textViewNumberValue, R.id.textViewType, R.id.textViewDate};

    CallLogAdapter adapter =
        new CallLogAdapter(this, R.layout.call_log_row, cursor, fromColumns, toColumns, 0);
    super.setListAdapter(adapter);

    callButton = (Button) findViewById(R.id.buttonCall);
  }
 @Override
 protected void onPostExecute(final List<AppInfo> results) {
   ListAdapter listAdapter =
       new ArrayAdapter<AppInfo>(
           activity, R.layout.app_picker_list_item, R.id.app_picker_list_item_label, results) {
         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
           View view = super.getView(position, convertView, parent);
           Drawable icon = results.get(position).getIcon();
           if (icon != null) {
             ((ImageView) view.findViewById(R.id.app_picker_list_item_icon))
                 .setImageDrawable(icon);
           }
           return view;
         }
       };
   activity.setListAdapter(listAdapter);
 }
Пример #3
0
  @Inject
  public Main(ListActivity listActivity, IntentFactory intentFactory) {

    this.intentFactory = intentFactory;
    this.listActivity = listActivity;

    values =
        new ArrayList<ActivityListItem>(
            Arrays.asList(
                new ActivityListItem[] {
                  createLI(Components.get(Preferences.class), "Preferences"),
                  createLI(Components.get(AOP.class), "AOP"),
                  createExtraLI(),
                  createLI(Components.get(Injection.class), "Injection"),
                  createLI(Components.get(ResourceInjection.class), "Resources"),
                  createLI(Components.get(SystemInjection.class), "System Services"),
                  createLI(Components.get(ActivityLifecycle.class), "Activity Lifecycle"),
                  createLI(Components.get(ScopeOne.class), "Singleton Scope One"),
                  createLI(Components.get(ScopeTwo.class), "Singleton Scope Two"),
                  createLI(NotManagedActivity.class, "Not Managed"),
                  createLI(Components.get(CustomView.class), "Custom View"),
                  createLI(Components.get(VariableLayout.class), "Variable Layout"),
                  createLI(Components.get(Register.class), "Listener Registration"),
                  createLI(ManifestManagedActivity.class, "Manifest Managed Activity"),
                  createLI(Components.get(ToastTrigger.class), "Broadcast Receiver"),
                  createLI(Components.get(PreferenceInjection.class), "Preference Injection"),
                  createLI(Components.get(ViewInjection.class), "View Injection"),
                  createLI(Components.get(FragmentMain.class), "Fragments"),
                  createLI(Components.get(EventObserver.class), "Event Observer"),
                  createLI(Components.get(SaveInstanceState.class), "Save Instance State"),
                  createLI(Components.get(NonConfigInstance.class), "NonConfiguration AsyncTask"),
                  createLI(Components.get(Listeners.class), "Activity Listeners"),
                  createLI(Components.get(Menu.class), "Menu")
                }));

    Collections.sort(values);

    values.add(createLI(Components.get(About.class), "About"));

    ArrayAdapter<ActivityListItem> adapter =
        new ArrayAdapter<ActivityListItem>(
            listActivity, android.R.layout.simple_list_item_1, values);
    listActivity.setListAdapter(adapter);
  }
  public static <LI extends ListItem> void attach(
      @Nonnull ListActivity listActivity, @Nonnull ListItemAdapter<? extends LI> adapter) {
    listActivity.setListAdapter(adapter);

    fillListView(listActivity.getListView(), adapter, listActivity);
  }