Example usage for android.widget ListView setAdapter

List of usage examples for android.widget ListView setAdapter

Introduction

In this page you can find the example usage for android.widget ListView setAdapter.

Prototype

@Override
public void setAdapter(ListAdapter adapter) 

Source Link

Document

Sets the data behind this ListView.

Usage

From source file:ca.six.unittestapp.todo.tasks.TasksFragment.java

@Nullable
@Override/*from  www . j  av a 2 s  .  co m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.tasks_frag, container, false);

    // Set up tasks view
    ListView listView = (ListView) root.findViewById(R.id.tasks_list);
    listView.setAdapter(mListAdapter);
    mFilteringLabelView = (TextView) root.findViewById(R.id.filteringLabel);
    mTasksView = (LinearLayout) root.findViewById(R.id.tasksLL);

    // Set up  no tasks view
    mNoTasksView = root.findViewById(R.id.noTasks);
    mNoTaskIcon = (ImageView) root.findViewById(R.id.noTasksIcon);
    mNoTaskMainView = (TextView) root.findViewById(R.id.noTasksMain);
    mNoTaskAddView = (TextView) root.findViewById(R.id.noTasksAdd);
    mNoTaskAddView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showAddTask();
        }
    });

    // Set up floating action button
    FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_task);

    fab.setImageResource(R.drawable.ic_add);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mPresenter.addNewTask();
        }
    });

    // Set up progress indicator
    final ScrollChildSwipeRefreshLayout swipeRefreshLayout = (ScrollChildSwipeRefreshLayout) root
            .findViewById(R.id.refresh_layout);
    swipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(getActivity(), R.color.colorPrimary),
            ContextCompat.getColor(getActivity(), R.color.colorAccent),
            ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark));
    // Set the scrolling view in the custom SwipeRefreshLayout.
    swipeRefreshLayout.setScrollUpChild(listView);

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mPresenter.loadTasks(false);
        }
    });

    setHasOptionsMenu(true);

    return root;
}

From source file:com.example.amit.tellymoviebuzzz.ImdbUpcomingFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // The CursorAdapter will take data from our cursor and populate the ListView.
    mForecastAdapter = new ImdbUpcomingAdapter(getActivity(), null, 0);

    View rootView = inflater.inflate(R.layout.imdbupcoming_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView = (ListView) rootView.findViewById(R.id.listview_imdbupcoming_movies);
    listView.setAdapter(mForecastAdapter);

    final String[] str1 = { "Action", "Adventure", "Animation", "Comedy", "Crime", "Documentary", "Drama",
            "Family", "Fantasy", "Foreign", "History", "Horror", "Music", "Mystery", "Romance",
            "Science Fiction", "TV Movie", "Thriller", "War", "Western", "Others" };

    Spinner sp2 = (Spinner) rootView.findViewById(R.id.spinnerupcomingyear);
    //final Spinner sp2= (Spinner) findViewById(R.id.spinner2);

    ArrayAdapter<String> adp2 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item,
            str1);/* ww w  .  ja  va  2 s  .com*/
    adp2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sp2.setAdapter(adp2);

    sp2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) {
            // TODO Auto-generated method stub
            // Toast.makeText(getBaseContext(),list.get(position), Toast.LENGTH_SHORT).show();

            String val = str1[position];

            Bundle bund = new Bundle();
            bund.putString("choice", val);
            // bund.
            getLoaderManager().restartLoader(FORECAST_LOADER, bund, ImdbUpcomingFragment.this);

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }

    });

    // Spinner spinner = (Spinner) rootView.findViewById(R.id.spinnerthisyear);

    /// String[] options = {"India","USA","UK"};

    // android.R.layout.support_simple_spinner_dropdown_item

    // We'll call our MainActivity
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            // CursorAdapter returns a cursor at the correct position for getItem(), or null
            // if it cannot seek to that position.
            Cursor cursor = (Cursor) adapterView.getItemAtPosition(position);
            if (cursor != null) {
                // String locationSetting = Utility.getPreferredLocation(getActivity());
                String movieSetting = "thisyear";
                //Utility.getPreferredMovie(getActivity());

                // Intent intent = new Intent(getActivity(), DetailActivity.class)
                //        .setData(WeatherContract.WeatherEntry.buildWeatherLocationWithDate(
                //               locationSetting, cursor.getLong(COL_WEATHER_DATE)
                //       ));
                // Intent intent = new Intent(getActivity(), DetailActivity.class)
                //         .setData(MovieContract.MovieNumberEntry.buildMovieTypeWithMovieId(movieSetting, cursor.getString(COL_MOVIE_SETTING)));

                Intent intent = new Intent(getActivity(), DetailActivity.class);
                // .setData(cursor.getString(ImdbUpcomingFragment.COL_TMDBID));
                intent.putExtra("movieid", cursor.getString(ImdbUpcomingFragment.COL_TMDBID));

                startActivity(intent);
            }
        }
    });
    return rootView;
}

From source file:com.example.amit.tellymoviebuzzz.ImdbFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // The CursorAdapter will take data from our cursor and populate the ListView.
    mForecastAdapter = new ImdbAdapter(getActivity(), null, 0);

    View rootView = inflater.inflate(R.layout.imdbthisyear_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView1 = (ListView) rootView.findViewById(R.id.listview_imdbthisyear_movies);
    listView1.setAdapter(mForecastAdapter);

    final String[] str = { "Action", "Adventure", "Animation", "Comedy", "Crime", "Documentary", "Drama",
            "Family", "Fantasy", "Foreign", "History", "Horror", "Music", "Mystery", "Romance",
            "Science Fiction", "TV Movie", "Thriller", "War", "Western", "Others" };

    Spinner sp1 = (Spinner) rootView.findViewById(R.id.spinnerthisyear);
    //final Spinner sp2= (Spinner) findViewById(R.id.spinner2);

    ArrayAdapter<String> adp1 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item,
            str);/*from  w w  w .ja  v  a2  s .  c o m*/
    adp1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sp1.setAdapter(adp1);

    sp1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) {
            // TODO Auto-generated method stub
            // Toast.makeText(getBaseContext(),list.get(position), Toast.LENGTH_SHORT).show();

            String val = str[position];

            Bundle bund = new Bundle();
            bund.putString("choice", val);
            // bund.
            getLoaderManager().restartLoader(FORECAST_LOADER, bund, ImdbFragment.this);

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }

    });

    // Spinner spinner = (Spinner) rootView.findViewById(R.id.spinnerthisyear);

    /// String[] options = {"India","USA","UK"};

    // android.R.layout.support_simple_spinner_dropdown_item

    // We'll call our MainActivity
    listView1.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            // CursorAdapter returns a cursor at the correct position for getItem(), or null
            // if it cannot seek to that position.
            Cursor cursor = (Cursor) adapterView.getItemAtPosition(position);
            if (cursor != null) {
                // String locationSetting = Utility.getPreferredLocation(getActivity());
                String movieSetting = "thisyear";
                //Utility.getPreferredMovie(getActivity());

                // Intent intent = new Intent(getActivity(), DetailActivity.class)
                //        .setData(WeatherContract.WeatherEntry.buildWeatherLocationWithDate(
                //               locationSetting, cursor.getLong(COL_WEATHER_DATE)
                //       ));
                // Intent intent = new Intent(getActivity(), DetailActivity.class)
                //         .setData(MovieContract.MovieNumberEntry.buildMovieTypeWithMovieId(movieSetting, cursor.getString(COL_MOVIE_SETTING)));

                Intent intent = new Intent(getActivity(), DetailActivity.class);
                // .setData(cursor.getString(ImdbFragment.COL_TMDBID));
                intent.putExtra("movieid", cursor.getString(ImdbFragment.COL_TMDBID));

                startActivity(intent);
            }
        }
    });
    return rootView;
}

From source file:com.csipsimple.ui.calllog.CallLogDetailsFragment.java

/**
 * Update user interface with details of given call.
 * //from   w  w  w .ja va2  s  .co  m
 * @param callUris URIs into {@link CallLog.Calls} of the calls to be
 *            displayed
 */
private void updateData(final Uri... callUris) {

    final int numCalls = callUris.length;
    PhoneCallDetails[] details = new PhoneCallDetails[numCalls];
    for (int index = 0; index < numCalls; ++index) {
        details[index] = getPhoneCallDetailsForUri(callUris[index]);
    }

    // We know that all calls are from the same number and the same contact,
    // so pick the
    // first.
    PhoneCallDetails firstDetails = details[0];
    final Uri contactUri = firstDetails.contactUri;
    final Uri photoUri = firstDetails.photoUri;

    // Set the details header, based on the first phone call.
    mPhoneCallDetailsHelper.setCallDetailsHeader(mHeaderTextView, firstDetails);

    // Cache the details about the phone number.
    // final Uri numberCallUri = mPhoneNumberHelper.getCallUri(mNumber);
    // final boolean canPlaceCallsTo =
    // mPhoneNumberHelper.canPlaceCallsTo(mNumber);
    // final boolean isVoicemailNumber =
    // mPhoneNumberHelper.isVoicemailNumber(mNumber);
    // final boolean isSipNumber = mPhoneNumberHelper.isSipNumber(mNumber);

    // Let user view contact details if they exist, otherwise add option to
    // create new
    // contact from this number.
    final Intent mainActionIntent;
    final int mainActionIcon;
    final String mainActionDescription;

    final CharSequence nameOrNumber;
    if (!TextUtils.isEmpty(firstDetails.name)) {
        nameOrNumber = firstDetails.name;
    } else {
        nameOrNumber = firstDetails.number;
    }

    if (contactUri != null) {
        mainActionIntent = new Intent(Intent.ACTION_VIEW, contactUri);
        mainActionIcon = R.drawable.ic_contacts_holo_dark;
        mainActionDescription = nameOrNumber.toString();
    } else if (!TextUtils.isEmpty(firstDetails.number)) {
        mainActionIntent = ContactsWrapper.getInstance().getAddContactIntent((String) firstDetails.name,
                (String) firstDetails.number);
        mainActionIcon = SipHome.USE_LIGHT_THEME ? R.drawable.ic_add_contact_holo_light
                : R.drawable.ic_add_contact_holo_dark;
        mainActionDescription = getString(R.string.menu_add_to_contacts);
        if (TextUtils.isEmpty(firstDetails.name)) {
            mHeaderTextView.setText(R.string.menu_add_to_contacts);
        } else {
            mHeaderTextView.setText(getString(R.string.menu_add_address_to_contacts, firstDetails.name));
        }
    } else {
        // If we cannot call the number, when we probably cannot add it as a
        // contact either.
        // This is usually the case of private, unknown, or payphone
        // numbers.
        mainActionIntent = null;
        mainActionIcon = 0;
        mainActionDescription = null;
    }

    if (mainActionIntent == null) {
        mMainActionView.setVisibility(View.INVISIBLE);
        mMainActionPushLayerView.setVisibility(View.GONE);
        mHeaderTextView.setVisibility(View.INVISIBLE);
        mHeaderOverlayView.setVisibility(View.INVISIBLE);
    } else {
        mMainActionView.setVisibility(View.VISIBLE);
        mMainActionView.setImageResource(mainActionIcon);
        mMainActionPushLayerView.setVisibility(View.VISIBLE);
        mMainActionPushLayerView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(mainActionIntent);
            }
        });
        mMainActionPushLayerView.setContentDescription(mainActionDescription);
        mHeaderTextView.setVisibility(View.VISIBLE);
        mHeaderOverlayView.setVisibility(View.VISIBLE);
    }

    // This action allows to call the number that places the call.
    // final CharSequence displayNumber = firstDetails.formattedNumber;
    CharSequence displayNumber;
    if (!TextUtils.isEmpty(firstDetails.number)) {
        displayNumber = SipUri.getCanonicalSipContact(firstDetails.number.toString(), false);
    } else {
        displayNumber = mResources.getString(R.string.unknown);
    }

    String callText = getString(R.string.call_number, displayNumber);
    configureCallButton(callText, firstDetails.numberLabel, firstDetails.number);

    ListView historyList = (ListView) getView().findViewById(R.id.history);
    historyList.setAdapter(new CallDetailHistoryAdapter(getActivity(), mInflater, details));

    mAccountChooserButton.setTargetAccount(firstDetails.accountId);
    loadContactPhotos(photoUri, contactUri);
}

From source file:com.example.android0128.introductionmvp.tasks.TasksFragment.java

@Nullable
@Override//from w  w w  .ja va 2  s.co m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.tasks_frag, container, false);

    // Set up tasks view
    ListView listView = (ListView) root.findViewById(R.id.tasks_list);
    listView.setAdapter(mListAdapter);
    mFilteringLabelView = (TextView) root.findViewById(R.id.filteringLabel);
    mTasksView = (LinearLayout) root.findViewById(R.id.tasksLL);

    // Set up  no tasks view
    mNoTasksView = root.findViewById(R.id.noTasks);
    mNoTaskIcon = (ImageView) root.findViewById(R.id.noTasksIcon);
    mNoTaskMainView = (TextView) root.findViewById(R.id.noTasksMain);
    mNoTaskAddView = (TextView) root.findViewById(R.id.noTasksAdd);
    mNoTaskAddView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showAddTask();
        }
    });

    // Set up floating action button
    /*FloatingActionButton fab =
        (FloatingActionButton) getActivity().findViewById(R.id.fab_add_task);
            
    fab.setImageResource(R.drawable.ic_add);
    fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        mPresenter.addNewTask();
    }
    });*/

    // Set up progress indicator
    /*final SwipeRefreshLayout swipeRefreshLayout =
        (SwipeRefreshLayout) root.findViewById(R.id.refresh_layout);
    swipeRefreshLayout.setColorSchemeColors(
        ContextCompat.getColor(getActivity(), R.color.colorPrimary),
        ContextCompat.getColor(getActivity(), R.color.colorAccent),
        ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark)
    );
    // Set the scrolling view in the custom SwipeRefreshLayout.
    swipeRefreshLayout.setScrollUpChild(listView);
            
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
        mPresenter.loadTasks(false);
    }
    });*/

    setHasOptionsMenu(true);

    return root;
}

From source file:com.android.settingslib.drawer.SettingsDrawerActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    long startTime = System.currentTimeMillis();

    TypedArray theme = getTheme().obtainStyledAttributes(android.R.styleable.Theme);
    if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
        getWindow().addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }/*from ww  w  .  j  ava 2s.  c  o m*/
    super.setContentView(R.layout.settings_with_drawer);
    mContentHeaderContainer = (FrameLayout) findViewById(R.id.content_header_container);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
    if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
        toolbar.setVisibility(View.GONE);
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        mDrawerLayout = null;
        return;
    }
    getDashboardCategories();
    setActionBar(toolbar);
    mDrawerAdapter = new SettingsDrawerAdapter(this);
    ListView listView = (ListView) findViewById(R.id.left_drawer);
    listView.setAdapter(mDrawerAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(android.widget.AdapterView<?> parent, View view, int position, long id) {
            onTileClicked(mDrawerAdapter.getTile(position));
        }
    });

    mUserManager = UserManager.get(this);
    if (DEBUG_TIMING)
        Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms");
}

From source file:devbox.com.br.minercompanion.ProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);


    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (networkInfo.isConnected()) {
        final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
        final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
        if (connectionInfo != null && !(connectionInfo.getSSID().equals(""))) {
            //if (connectionInfo != null && !StringUtil.isBlank(connectionInfo.getSSID())) {
            routerName = connectionInfo.getSSID();
        }/*from   www . j a v a 2 s  .  co m*/
    }

    sensorCounter = new SensorCounter(3000, 3000);
    sensorCounter.start();

    Intent intent = getIntent();

    if(intent != null) {
        matricula = intent.getStringExtra("MATRICULA");

        TextView textView = (TextView) findViewById(R.id.textView);

        textView.setText("Matrcula: " + matricula);

        sensors = new Sensors(matricula, routerName.replace("\"",""));
    }

    /* Get a SensorManager instance */
    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    ListView listView = (ListView) findViewById(R.id.listView);
    profileListAdapter = new ProfileListAdapter(this, strings);
    listView.setAdapter(profileListAdapter);

    profileListAdapter.addItem("Conectado ao servidor!");
}

From source file:com.abcvoipsip.ui.calllog.CallLogDetailsFragment.java

/**
 * Update user interface with details of given call.
 * //from   w w w  . j  a v  a  2 s  .co  m
 * @param callUris URIs into {@link CallLog.Calls} of the calls to be
 *            displayed
 */
private void updateData(final Uri... callUris) {

    final int numCalls = callUris.length;
    if (numCalls == 0) {
        Log.w(THIS_FILE, "No calls logs as parameters");
        return;
    }

    PhoneCallDetails[] details = new PhoneCallDetails[numCalls];
    for (int index = 0; index < numCalls; ++index) {
        details[index] = getPhoneCallDetailsForUri(callUris[index]);
    }

    // We know that all calls are from the same number and the same contact,
    // so pick the
    // first.
    PhoneCallDetails firstDetails = details[0];
    final Uri contactUri = firstDetails.contactUri;
    final Uri photoUri = firstDetails.photoUri;

    // Set the details header, based on the first phone call.
    mPhoneCallDetailsHelper.setCallDetailsHeader(mHeaderTextView, firstDetails);

    // Cache the details about the phone number.
    // final Uri numberCallUri = mPhoneNumberHelper.getCallUri(mNumber);
    // final boolean canPlaceCallsTo =
    // mPhoneNumberHelper.canPlaceCallsTo(mNumber);
    // final boolean isVoicemailNumber =
    // mPhoneNumberHelper.isVoicemailNumber(mNumber);
    // final boolean isSipNumber = mPhoneNumberHelper.isSipNumber(mNumber);

    // Let user view contact details if they exist, otherwise add option to
    // create new
    // contact from this number.
    final Intent mainActionIntent;
    final int mainActionIcon;
    final String mainActionDescription;

    final CharSequence nameOrNumber;
    if (!TextUtils.isEmpty(firstDetails.name)) {
        nameOrNumber = firstDetails.name;
    } else {
        nameOrNumber = firstDetails.number;
    }

    if (contactUri != null) {
        mainActionIntent = new Intent(Intent.ACTION_VIEW, contactUri);
        mainActionIcon = R.drawable.ic_contacts_holo_dark;
        mainActionDescription = nameOrNumber.toString();
    } else if (!TextUtils.isEmpty(firstDetails.number)) {
        mainActionIntent = ContactsWrapper.getInstance().getAddContactIntent((String) firstDetails.name,
                (String) firstDetails.number);
        mainActionIcon = SipHome.USE_LIGHT_THEME ? R.drawable.ic_add_contact_holo_light
                : R.drawable.ic_add_contact_holo_dark;
        mainActionDescription = getString(R.string.menu_add_to_contacts);
        if (TextUtils.isEmpty(firstDetails.name)) {
            mHeaderTextView.setText(R.string.menu_add_to_contacts);
        } else {
            mHeaderTextView.setText(getString(R.string.menu_add_address_to_contacts, firstDetails.name));
        }
    } else {
        // If we cannot call the number, when we probably cannot add it as a
        // contact either.
        // This is usually the case of private, unknown, or payphone
        // numbers.
        mainActionIntent = null;
        mainActionIcon = 0;
        mainActionDescription = null;
    }

    if (mainActionIntent == null) {
        mMainActionView.setVisibility(View.INVISIBLE);
        mMainActionPushLayerView.setVisibility(View.GONE);
        mHeaderTextView.setVisibility(View.INVISIBLE);
        mHeaderOverlayView.setVisibility(View.INVISIBLE);
    } else {
        mMainActionView.setVisibility(View.VISIBLE);
        mMainActionView.setImageResource(mainActionIcon);
        mMainActionPushLayerView.setVisibility(View.VISIBLE);
        mMainActionPushLayerView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(mainActionIntent);
            }
        });
        mMainActionPushLayerView.setContentDescription(mainActionDescription);
        mHeaderTextView.setVisibility(View.VISIBLE);
        mHeaderOverlayView.setVisibility(View.VISIBLE);
    }

    // This action allows to call the number that places the call.
    // final CharSequence displayNumber = firstDetails.formattedNumber;
    CharSequence displayNumber;
    if (!TextUtils.isEmpty(firstDetails.number)) {
        displayNumber = SipUri.getCanonicalSipContact(firstDetails.number.toString(), false);
    } else {
        displayNumber = mResources.getString(R.string.unknown);
    }

    String callText = getString(R.string.description_call, displayNumber);
    configureCallButton(callText, firstDetails.numberLabel, firstDetails.number);

    ListView historyList = (ListView) getView().findViewById(R.id.history);
    historyList.setAdapter(new CallDetailHistoryAdapter(getActivity(), mInflater, details));

    mAccountChooserButton.setTargetAccount(firstDetails.accountId);
    loadContactPhotos(photoUri, contactUri);
}

From source file:com.myandroidremote.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *///from  www .  j  a va  2  s.  com
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
            }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                showLoadingScreen();
            }
        });
        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();
    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Register in the background and terminate the activity
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                register((String) account.getText());

                // show connecting
                showLoadingScreen();
            }
        });

        final Button exitButton = (Button) findViewById(R.id.exit);
        exitButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                finish();
            }
        });
    }
}

From source file:com.example.meetingapp.OptionsFragment.java

private void setupFriends() {
    ListView view = (ListView) mLayout.findViewById(R.id.locations_list);
    mAdapter = new ArrayAdapter<String>(getActivity(), R.layout.friend_item, mAddresses);
    view.setAdapter(mAdapter);
}