当前位置: 首页>>代码示例>>Java>>正文


Java ListView.setAdapter方法代码示例

本文整理汇总了Java中android.widget.ListView.setAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java ListView.setAdapter方法的具体用法?Java ListView.setAdapter怎么用?Java ListView.setAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ListView的用法示例。


在下文中一共展示了ListView.setAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setCharacterList

import android.widget.ListView; //导入方法依赖的package包/类
private void setCharacterList(){

        ListView character_list = (ListView) findViewById(R.id.character_list);
        final ArrayAdapter<Character> adapter = new RowAdapter(this,characters);
        character_list.setAdapter(adapter);

        character_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                boolean isSelected = characters.get(i).isActive() ? false : true;
                characters.get(i).setActive(isSelected);
                adapter.notifyDataSetChanged();

            }
        });

    }
 
开发者ID:jleon95,项目名称:LearnHangul,代码行数:19,代码来源:CharactersActivity.java

示例2: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_content_consumer);
    ListView lv_pessoas = (ListView) findViewById(R.id.lv_Pessoas);
    ContentResolver cr = getContentResolver();
    //consulta na main thread, pode ser custoso, usar AsyncTask ou Loader
    Cursor c = cr.query(ContentProviderContract.CONTENT_LIST_URI, null, null, null, null);
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(
                    this,
                    R.layout.itemlista,
                    c,
                    new String[] {ContentProviderContract.NOME},
                    new int[] {R.id.pNome},
                    0);
    lv_pessoas.setAdapter(adapter);
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:19,代码来源:ContentConsumerActivity.java

示例3: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_list);

    ListView list = (ListView) findViewById(R.id.list);
    list.setAdapter(AttributionPresenterCreator.create(
            this,
            new OnAttributionClickListener() {
                @Override
                public boolean onAttributionClick(Attribution attribution) {
                    Toast.makeText(getApplicationContext(), "Attribution click: " + attribution.getName(), Toast.LENGTH_SHORT).show();
                    return false;
                }
            },
            new OnLicenseClickListener() {
                @Override
                public boolean onLicenseClick(LicenseInfo licenseInfo) {
                    Toast.makeText(getApplicationContext(), "License click: " + licenseInfo.getName(), Toast.LENGTH_SHORT).show();
                    return true;
                }
            }).getAdapter());
}
 
开发者ID:franmontiel,项目名称:AttributionPresenter,代码行数:25,代码来源:ListActivity.java

示例4: initView

import android.widget.ListView; //导入方法依赖的package包/类
private void initView() {
    try {
        title = (TextView) findViewById(R.id.udesk_title);
        listView = (ListView) findViewById(R.id.udesk_options_listview);
        mTitlebar = (UdeskTitleBar) findViewById(R.id.udesktitlebar);
        adapter = new OptionsAgentGroupAdapter(this);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(this);
        title.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                backParentView();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:lennyup,项目名称:react-native-udesk,代码行数:19,代码来源:UdeskOptionsAgentGroupActivity.java

示例5: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_listview_chart);
    
    ListView lv = (ListView) findViewById(R.id.listView1);

    ArrayList<BarData> list = new ArrayList<BarData>();

    // 20 items
    for (int i = 0; i < 20; i++) {
        list.add(generateData(i + 1));
    }

    ChartDataAdapter cda = new ChartDataAdapter(getApplicationContext(), list);
    lv.setAdapter(cda);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ListViewBarChartActivity.java

示例6: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    android.content.Intent intent = getIntent();

    beverageName = intent.getStringExtra(beverageNameKey);
    beverageVolume = intent.getDoubleExtra(beverageVolumeKey, 0.0);
    beverageAlcoholicStrength = intent.getDoubleExtra(beverageAlcoholicKey, 0.0);

    bartour = Bartout.getInstance().getActiveBartour();
    users = bartour.getUsers();

    editTextBeverageName = (EditText) findViewById(R.id.editTextBeverageName);
    editTextBeverageVolume = (EditText) findViewById(R.id.editTextBeverageVolume);
    editTextAlcoholicStrength = (EditText) findViewById(R.id.editTextBeverageAlcoholicStrength);

    editTextBeverageName.setText(beverageName);
    editTextBeverageVolume.setText(Double.toString(beverageVolume));
    editTextAlcoholicStrength.setText(Double.toString(beverageAlcoholicStrength));

    listViewUsers = (ListView) findViewById(R.id.listViewDrinkUsers);

    UserBeverageAdapter userBeverageAdapter = new UserBeverageAdapter(this, users);
    listViewUsers.setAdapter(userBeverageAdapter);

}
 
开发者ID:Bartout-Team,项目名称:Bartout,代码行数:27,代码来源:DrinkBeverageActivity.java

示例7: initWidgets

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void initWidgets() {
    super.initWidgets();
    mBackImg = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImg.setOnClickListener(this);
    mListView = (ListView) findViewById(R.id.kf5_activity_order_attr_list_view);
    mUserFields = new ArrayList<>();
    mUserFieldAdapter = new UserFieldAdapter(mActivity, mUserFields);
    mListView.setAdapter(mUserFieldAdapter);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:11,代码来源:OrderAttributeActivity.java

示例8: onCreateView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_followers, container, false);

    userId = CurrentUser.getInstance().getUserId();

    // Get follow requests where I am the followee and the request has been accepted
    followersDataSource = new FollowRequestDataSource(null, userId);
    followersDataSource.setOnlyShowAccepted(true);
    followersDataSource.addObserver(this);
    followers = followersDataSource.getSource();

    // Get follow requests that I have sent
    followRequestDataSource = new FollowRequestDataSource(userId, null);
    followRequestDataSource.addObserver(this);
    followRequests = followRequestDataSource.getSource();

    // Get all users
    userDataSource = new UserDataSource(userId);
    userDataSource.addObserver(this);
    users = userDataSource.getSource();

    followRequestsListView = (ListView) view.findViewById(R.id.followersListView);
    followersAdapter = new FollowersAdapter(getActivity(), followers, users, followRequests);
    followRequestsListView.setAdapter(followersAdapter);

    return view;
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:30,代码来源:FollowersFragment.java

示例9: initView

import android.widget.ListView; //导入方法依赖的package包/类
private void initView() {
    QuickIndexBar quickIndexBar = (QuickIndexBar) findViewById(R.id.quick_index_bar);
    listView = (ListView) findViewById(R.id.list_view);
    tvCurrentWord = (TextView) findViewById(R.id.tv_current_word);

    prepareData(); // 虚拟数据
    Collections.sort(friends); // 排序
    listView.setAdapter(new FriendAdapter(this, friends));

    quickIndexBar.setOnTouchLetterListener(new QuickIndexBar.OnTouchLetterListener() {
        @Override
        public void onTouchLetter(String letter) {
            //根据当前触摸的字母,去集合中找那个 item 的首字母和 letter 一样,然后将对应的item放到屏幕顶端
            for (int i = 0; i < friends.size(); i++) {
                String firstWord = friends.get(i).getPinYin().charAt(0) + "";
                if (letter.equals(firstWord)) {
                    // 说明找到了,那么应该讲当前的 item 放到屏幕顶端
                    listView.setSelection(i);
                    break;
                }
            }
            // 显示当前触摸的字母
            showCurrentWord(letter);
        }
    });

    // 通过缩小 tvCurrentWord 来隐藏
    ViewHelper.setScaleX(tvCurrentWord, 0f);
    ViewHelper.setScaleY(tvCurrentWord, 0f);
}
 
开发者ID:sleticalboy,项目名称:CustomWeight,代码行数:31,代码来源:MainActivity.java

示例10: initPullToRefreshListView

import android.widget.ListView; //导入方法依赖的package包/类
private void initPullToRefreshListView() {
    mData = new ArrayList<>();
    mAdapter = new NearbyListAdapter(getContext(), mData, mLongitude, mLatitude, getActivity());
    ListView listView = mPullToRefreshNearbylist.getRefreshableView();
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long id) {
            Intent intent = new Intent(getContext(), PersonalHomeActivity.class);
            intent.putExtra("other_by_id",mData.get(i-1).getUserid());
            startActivity(intent);
        }
    });

}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:16,代码来源:NearbyListFragment.java

示例11: DisplaySocketListViewDialog

import android.widget.ListView; //导入方法依赖的package包/类
public void DisplaySocketListViewDialog(SerializableList<WirelessSocket> wirelessSocketList) {
    final Dialog dialog = createDialog();
    dialog.setContentView(R.layout.dialog_listview);

    TextView titleView = dialog.findViewById(R.id.dialog_title_text_view);
    titleView.setText("Wireless Sockets");

    com.rey.material.widget.Button closeButton = dialog.findViewById(R.id.dialog_button_close);
    closeButton.setOnClickListener(v -> dialog.dismiss());

    ListView listView = dialog.findViewById(R.id.dialog_list_view);
    listView.setAdapter(new SocketListViewAdapter(_context, wirelessSocketList, dialog));

    displayDialog(dialog);
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:16,代码来源:DialogController.java

示例12: BelowView

import android.widget.ListView; //导入方法依赖的package包/类
/**
 * Instantiates a new Below view.
 *
 * @param c        the c
 * @param listName the list name
 */
public BelowView(@NonNull Context c, @Nullable List<String> listName) {
    this.convertView = View.inflate(c, R.layout.simple_exo_belowview, null);
    listView = (ListView) convertView.findViewById(R.id.list_item);
    if (listName == null) {
        listName = Arrays.asList(c.getResources().getStringArray(R.array.exo_video_switch_text));
    }
    adapter = new SwitchAdapter(c, listName);
   listView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
    listView.setAdapter(adapter);
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:17,代码来源:BelowView.java

示例13: onCreateDialog

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.sync_passphrase_types, null);

    // Configure the passphrase type list
    ListView list = (ListView) v.findViewById(R.id.passphrase_types);
    Adapter adapter = createAdapter(getCurrentTypeFromArguments());
    list.setAdapter(adapter);
    list.setId(R.id.passphrase_type_list);
    list.setOnItemClickListener(this);
    list.setDividerHeight(0);
    PassphraseType currentType = getCurrentTypeFromArguments();
    list.setSelection(adapter.getPositionForType(currentType));

    // Configure the hint to reset the passphrase settings
    // Only show this hint if encryption has been set to use sync passphrase
    if (currentType == PassphraseType.CUSTOM_PASSPHRASE) {
        TextView instructionsView = (TextView) v.findViewById(R.id.reset_sync_text);
        instructionsView.setVisibility(View.VISIBLE);
        instructionsView.setMovementMethod(LinkMovementMethod.getInstance());
        instructionsView.setText(getResetText());
    }

    // Create and return the dialog
    return new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setNegativeButton(R.string.cancel, this)
            .setTitle(R.string.sync_passphrase_type_title)
            .setView(v)
            .create();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:32,代码来源:PassphraseTypeDialogFragment.java

示例14: onCreateView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.choose_area, container, false);
    titleText = (TextView) view.findViewById(R.id.title_text);
    backButton = (Button) view.findViewById(R.id.back_button);
    listView = (ListView) view.findViewById(R.id.list_view);
    adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, dataList);
    view.setBackgroundColor(0xffffffff);
    listView.setAdapter(adapter);
    return view;
}
 
开发者ID:zjutcmos,项目名称:HappyWeather,代码行数:13,代码来源:ChooseAreaFragment.java

示例15: initializeNotificationsList

import android.widget.ListView; //导入方法依赖的package包/类
private void initializeNotificationsList() {
	listView = (ListView) findViewById(R.id.list_notifications_view);

	ArrayAdapter<ConfigurationOption> adapter = new ArrayAdapter<ConfigurationOption>(this.getBaseContext(), android.R.layout.simple_list_item_1);
	adapter.add(new ConfigurationOption(IncomingCallConfigActivity.class, getString(R.string.incoming_call_config)));
	adapter.add(new ConfigurationOption(WhatsappConfigActivity.class, getString(R.string.whatsapp_config)));
	adapter.add(new ConfigurationOption(GenericNotificationsActivity.class, getString(R.string.custom_notification_config)));
	listView.setAdapter(adapter);
	listView.setOnItemClickListener(new OnConfigurationOptionSelected(this, listView));
}
 
开发者ID:masterjc,项目名称:bluewatcher,代码行数:11,代码来源:NotificationsActivity.java


注:本文中的android.widget.ListView.setAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。