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


Java ListView类代码示例

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


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

示例1: updatePodcastRows

import android.widget.ListView; //导入依赖的package包/类
private void updatePodcastRows() {
    ListView list = getListView();
    int first = list.getFirstVisiblePosition();
    int last = list.getLastVisiblePosition();
    for (int i = first; i <= last; i++) {
        View view = list.getChildAt(i - first);
        list.getAdapter().getView(i, view, list);
    }
}
 
开发者ID:kalikov,项目名称:lighthouse,代码行数:10,代码来源:PodcastsActivity.java

示例2: setListItemLongClick

import android.widget.ListView; //导入依赖的package包/类
private void setListItemLongClick(ListView listView) {
    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, final int pos, long id) {
            PopupMenu popup = new PopupMenu(TaskActivity.this, view);
            popup.inflate(R.menu.task_item);
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    TaskEntity task = (TaskEntity) mAdapter.getItem(pos - 1);
                    handleTaskPopupAction(item, task);
                    return true;
                }
            });
            popup.show();
            return true;
        }
    });
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:20,代码来源:TaskActivity.java

示例3: actionModeDelete

import android.widget.ListView; //导入依赖的package包/类
private void actionModeDelete() {
    ListView lv = getListView();
    
    ArrayList<Long> checkedIds = new ArrayList<Long>();
    
    for(int i = 0; i < lv.getCount(); i++) {
        if(lv.isItemChecked(i)) {
            long[] selectedIds = mAdapter.getCallIdsAtPosition(i);
            
            for(long id : selectedIds) {
                checkedIds.add(id);
            }
            
        }
    }
    if(checkedIds.size() > 0) {
        String strCheckedIds = TextUtils.join(", ", checkedIds);
        Log.d(THIS_FILE, "Checked positions ("+ strCheckedIds +")");
        getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, Calls._ID + " IN ("+strCheckedIds+")", null);
        mMode.finish();
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:23,代码来源:CallLogListFragment.java

示例4: 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

示例5: onCreate

import android.widget.ListView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.habit_list);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    IOManager.initManager(getApplicationContext());
    lv = (ListView) findViewById(R.id.listOfUserHabits);
    addHabitBtn = (ImageButton) findViewById(R.id.addNewHabit);
    try {
        HabitListController.initHabitList();
        HabitListController.getHabitList().addObserver(this);
    } catch (NetworkUnavailableException e){
        Toast.makeText(this, "You must be connected to a network" +
                " to view, edit, and add habits.", Toast.LENGTH_LONG).show();
        finish();
    }
    initListeners();
}
 
开发者ID:CMPUT301F17T23,项目名称:routineKeen,代码行数:19,代码来源:HabitListActivity.java

示例6: onListItemClick

import android.widget.ListView; //导入依赖的package包/类
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    if (((GlobalValues) getActivity().getApplication()).CanCreateVariable()) {
        Matrix m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(position);
        Matrix clone;
        clone = m.ExactClone("Copy_" + m.GetName());
        ((GlobalValues) getActivity().getApplication()).GetCompleteList().add(clone);
        ((GlobalValues) getActivity().getApplication()).matrixAdapter.notifyDataSetChanged();
        Toast.makeText(getContext(), "Saved as Copy_" + m.GetName(), Toast.LENGTH_SHORT).show();
        NavigationView view = (NavigationView) getActivity().findViewById(R.id.nav_view);
        view.setCheckedItem(R.id.Home);
        FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.MainContent, new MainActivityFragmentList());
        transaction.commit();
        ((MainActivity) getActivity()).SetMainActivity(true, getString(R.string.app_name), getString(R.string.MainSubtitle));
    } else {
        if (!((GlobalValues) getActivity().getApplication()).AdLoaded)
            Toast.makeText(getContext(), R.string.ToAddMoreTurnData, Toast.LENGTH_SHORT).show();
        else
            Toast.makeText(getContext(), R.string.LimitExceeds, Toast.LENGTH_SHORT).show();
    }


}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:25,代码来源:CloneFragment.java

示例7: testEdit

import android.widget.ListView; //导入依赖的package包/类
/**
 * Test to make sure the edit button actually modifies the event
 */
public void testEdit(){

    if (((ListView)solo.getView(R.id.historyList)).getAdapter().getCount() > 0){
        solo.clickInList(1, 0);
        solo.sleep(2000);
        solo.assertCurrentActivity("wrong activity", HabitEventViewActivity.class);
        solo.clearEditText(0);
        solo.sleep(600);
        solo.enterText(0, "newcomment");
        solo.sleep(600);
        solo.clickOnButton("Save");
        solo.sleep(2000);
        solo.assertCurrentActivity("wrong activity", HistoryActivity.class);
        solo.clickInList(1, 0);
        solo.sleep(3000);
        solo.assertCurrentActivity("wrong activity", HabitEventViewActivity.class);
        // make sure the comment was changed
        assertTrue(((EditText)solo.getView(R.id.vheCommentDynamicText)).getText().toString().equals("newcomment"));

    }
}
 
开发者ID:CMPUT301F17T15,项目名称:CIA,代码行数:25,代码来源:ViewHabitEventIntentTests.java

示例8: initViews

import android.widget.ListView; //导入依赖的package包/类
private void initViews() {
    DialogAdapter dialogAdapter=new DialogAdapter(mName);
    ListView dialogList=(ListView) findViewById(R.id.dialog_list);
    Button mMBtnCancel = (Button) findViewById(R.id.mBtn_Cancel);
    TextView mTvTitle = (TextView) findViewById(R.id.mTv_Title);

    dialogList.setOnItemClickListener(this);
    dialogList.setAdapter(dialogAdapter);
    mMBtnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(mCancelListener != null){
                mCancelListener.onCancelClick(v);
            }
            dismiss();
        }
    });

    if(!TextUtils.isEmpty(mTitle)){
        mTvTitle.setVisibility(View.VISIBLE);
        mTvTitle.setText(mTitle);
    }else{
        mTvTitle.setVisibility(View.GONE);
    }
}
 
开发者ID:yangchong211,项目名称:YCDialog,代码行数:26,代码来源:CustomSelectDialog.java

示例9: init

import android.widget.ListView; //导入依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    this.context = context;
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.EaseContactList);
    primaryColor = ta.getColor(R.styleable.EaseContactList_ctsListPrimaryTextColor, 0);
    primarySize = ta.getDimensionPixelSize(R.styleable.EaseContactList_ctsListPrimaryTextSize, 0);
    showSiderBar = ta.getBoolean(R.styleable.EaseContactList_ctsListShowSiderBar, true);
    initialLetterBg = ta.getDrawable(R.styleable.EaseContactList_ctsListInitialLetterBg);
    initialLetterColor = ta.getColor(R.styleable.EaseContactList_ctsListInitialLetterColor, 0);
    ta.recycle();


    LayoutInflater.from(context).inflate(R.layout.ease_widget_contact_list, this);
    listView = (ListView) findViewById(R.id.list);
    sidebar = (EaseSidebar) findViewById(R.id.sidebar);
    if (!showSiderBar)
        sidebar.setVisibility(View.GONE);
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:18,代码来源:ContactList.java

示例10: onKeyDown

import android.widget.ListView; //导入依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Shortcuts that work no matter what is selected
    if (QMail.useVolumeKeysForListNavigationEnabled() &&
            (keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
            keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {

        final ListView listView = getListView();

        int currentPosition = listView.getSelectedItemPosition();
        if (currentPosition == AdapterView.INVALID_POSITION || listView.isInTouchMode()) {
            currentPosition = listView.getFirstVisiblePosition();
        }

        if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && currentPosition > 0) {
            listView.setSelection(currentPosition - 1);
        } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN &&
                currentPosition < listView.getCount()) {
            listView.setSelection(currentPosition + 1);
        }

        return true;
    }

    return super.onKeyDown(keyCode, event);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:27,代码来源:K9ListActivity.java

示例11: onCreateView

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

    // Inflate chess.com logo
    View header = inflater.inflate(R.layout.list_settings_header, null);
    header.setOnClickListener(mHeaderClickListener);

    // Init ListView
    mListView = (ListView) v.findViewById(R.id.list_time_controls);
    mListView.addHeaderView(header, null, false);
    mListView.setOnItemClickListener(mItemClickListener);

    // Set start button listener
    mStartBtn = v.findViewById(R.id.btn_start);
    mStartBtn.setOnClickListener(mStartBtnListener);

    // Set List Adapter and selection positions.
    setupListView(savedInstanceState);

    return v;
}
 
开发者ID:ChessCom,项目名称:android-chessclock,代码行数:23,代码来源:SettingsFragment.java

示例12: 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

示例13: setListViewHeightBasedOnChildren

import android.widget.ListView; //导入依赖的package包/类
/***
 * 动态设置listview的高度
 * 
 * @param listView
 */
public void setListViewHeightBasedOnChildren(ListView listView) {
	ListAdapter listAdapter = listView.getAdapter();
	if (listAdapter == null) {
		return;
	}
	int totalHeight = 0;
	for (int i = 0; i < listAdapter.getCount(); i++) {
		View listItem = listAdapter.getView(i, null, listView);
		listItem.measure(0, 0);
		totalHeight += listItem.getMeasuredHeight();
	}
	ViewGroup.LayoutParams params = listView.getLayoutParams();
	params.height = totalHeight
			+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
	// params.height += 5;// if without this statement,the listview will be
	// a
	// little short
	// listView.getDividerHeight()获取子项间分隔符占用的高度
	// params.height最后得到整个ListView完整显示需要的高度
	listView.setLayoutParams(params);
}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:27,代码来源:EditProvinceActivity.java

示例14: onLoadFinished

import android.widget.ListView; //导入依赖的package包/类
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // Swap the new cursor in.  (The framework will take care of closing the
    // old cursor once we return.)
    lAdapter.swapCursor(data);
    getListView().postDelayed(new Runnable() {
        @Override
        public void run() {
            ListView lv = getListView();
            if(selecting) {
                if (selectedLabelId == -1L){
                    // Set headerview as checked
                    lv.setItemChecked(0, true);
                } else {
                    lv.setItemChecked(getAdapterItemPosition(selectedLabelId) + lv.getHeaderViewsCount(), true);
                }
            }
        }
    }, 100);

}
 
开发者ID:danlls,项目名称:Todule-android,代码行数:22,代码来源:ToduleLabelFragment.java

示例15: onCreateView

import android.widget.ListView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  listView = (ListView) inflater.inflate(R.layout.venstremenu_frag, container, false);
  listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
      venstremenuAdapter.vælgMenu(getActivity(), position);
    }
  });
  venstremenuAdapter = new VenstremenuAdapter(getActivity());
  listView.setAdapter(venstremenuAdapter);
  listView.setItemChecked(mCurrentSelectedPosition, true);
  for (Backend b : App.backend) b.favoritter.observatører.add(this);
  App.data.hentedeUdsendelser.observatører.add(this);
  Alarms.setNextAlert(getActivity());
  return listView;
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:18,代码来源:Venstremenu_frag.java


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