Java Code Examples for android.widget.ListView

The following are top voted examples for showing how to use android.widget.ListView. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: lighthouse   File: PodcastsActivity.java   View source code 8 votes vote down vote up
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);
    }
}
 
Example 2
Project: andcouchbaseentity   File: TaskActivity.java   View source code 7 votes vote down vote up
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;
        }
    });
}
 
Example 3
Project: CSipSimple   File: CallLogListFragment.java   View source code 7 votes vote down vote up
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();
    }
}
 
Example 4
Project: LearnHangul   File: CharactersActivity.java   View source code 6 votes vote down vote up
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();

            }
        });

    }
 
Example 5
Project: routineKeen   File: HabitListActivity.java   View source code 6 votes vote down vote up
@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();
}
 
Example 6
Project: Matrix-Calculator-for-Android   File: CloneFragment.java   View source code 6 votes vote down vote up
@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();
    }


}
 
Example 7
Project: CIA   File: ViewHabitEventIntentTests.java   View source code 6 votes vote down vote up
/**
 * 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"));

    }
}
 
Example 8
Project: YCDialog   File: CustomSelectDialog.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 9
Project: GCSApp   File: ContactList.java   View source code 6 votes vote down vote up
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);
}
 
Example 10
Project: q-mail   File: K9ListActivity.java   View source code 6 votes vote down vote up
@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);
}
 
Example 11
Project: android-chessclock   File: SettingsFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 12
Project: Bartout   File: DrinkBeverageActivity.java   View source code 6 votes vote down vote up
@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);

}
 
Example 13
Project: HiBangClient   File: EditProvinceActivity.java   View source code 6 votes vote down vote up
/***
 * 动态设置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);
}
 
Example 14
Project: Todule-android   File: ToduleLabelFragment.java   View source code 6 votes vote down vote up
@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);

}
 
Example 15
Project: EsperantoRadio   File: Venstremenu_frag.java   View source code 6 votes vote down vote up
@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;
}
 
Example 16
Project: privacyidea-authenticator   File: MainActivityTest.java   View source code 6 votes vote down vote up
private int getAdapterCount(){
    final int[] counts = new int[1];
    onView(withId(R.id.listview)).check(matches(new TypeSafeMatcher<View>() {
        @Override
        public boolean matchesSafely(View view) {
            ListView listView = (ListView) view;

            counts[0] = listView.getCount();

            return true;
        }

        @Override
        public void describeTo(Description description) {

        }
    }));
    return counts[0];
}
 
Example 17
Project: TrackPlan-app   File: MainteachersActivity.java   View source code 6 votes vote down vote up
void check()
{ListView listView=(ListView)findViewById(R.id.lvt);
    Databaseteaclass db1 = new Databaseteaclass(getApplicationContext());
    List<Teacherclass> contacts = db1.getAllContacts();

    for (Teacherclass cn : contacts) {
        Log.d("cccccc", cn.getName());
        stringArrayList.add(cn.getName());
        stringArrayList1.add(cn.getcName());

}
    lviewAdapter = new ListViewAdteach(MainteachersActivity.this, stringArrayList1, stringArrayList);
    listView.setAdapter(lviewAdapter);



}
 
Example 18
Project: pracler   File: ProfileMenuAdapter.java   View source code 6 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
    if (convertView == null)
    {
        convertView = new ProfileRow(context);
        ListView.LayoutParams layoutParams = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.MATCH_PARENT);
        convertView.setLayoutParams(layoutParams);
    }

    final ProfileRow v = (ProfileRow) convertView;

    v.setText(followingList.get(position).name);
    UpdateView updateView = new UpdateView();
    updateView.setImageView(v.imageView);
    updateView.execute(followingList.get(position).picture);

    convertView = v;

    return convertView;
}
 
Example 19
Project: eddystone-beacon   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    beaconList = (ListView) findViewById(R.id.beacon_list);

    beaconManager = BeaconManager.getInstanceForApplication(this);

    // Detect the main identifier (UID) frame:
    beaconManager.getBeaconParsers().add(new BeaconParser().
            setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));

    // Detect the telemetry (TLM) frame:
    beaconManager.getBeaconParsers().add(new BeaconParser().
            setBeaconLayout(BeaconParser.EDDYSTONE_TLM_LAYOUT));

    // Detect the URL frame:
    beaconManager.getBeaconParsers().add(new BeaconParser().
            setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT));

    beaconManager.bind(this);
}
 
Example 20
Project: Wireless-Programming-Works   File: DivisionActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_division);

    Bundle dataBundle = getIntent().getExtras();
    Data data = (Data) dataBundle.getSerializable("data");
    String div_name = dataBundle.getString("div");

    bg = (ImageView) findViewById(R.id.division_image);
    placeList = (ListView) findViewById(R.id.place_list);
    divisionName = (TextView) findViewById(R.id.division_name);
    divisionName.setText(data.getDivisionName(div_name));

    bg.setImageResource(data.getImageRes(div_name));
    System.out.println(data.getPlaces(div_name));
    ArrayAdapter<String> adapter = new ArrayAdapter<String> (DivisionActivity.this, android.R.layout.simple_list_item_1,  data.getPlaces(div_name));
    placeList.setAdapter(adapter);

}
 
Example 21
Project: My-Day   File: DayView.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_day_view);

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);

    int width = dm.widthPixels;
    int height = dm.heightPixels;

    getWindow().setLayout((int) (width*.80), (int) (height*.80));

    dateText = (TextView) findViewById(R.id.tasklist_date);
    list = (ListView) findViewById(R.id.task_list);

    db = new DatabaseHandler(getApplicationContext());

    adapter = new TaskListAdapter(this, R.layout.task_row, db.getTaskOfDate(getIntent().getStringExtra("date")));

    list.setAdapter(adapter);
    adapter.notifyDataSetChanged();
}
 
Example 22
Project: EasyUpdateApplication   File: ms_AlertDialog.java   View source code 6 votes vote down vote up
private void initAlertDialog(Context context)
{
	layout = LayoutInflater.from(context).inflate(R.layout.ms_dialog, null);
	
	custom_view = (ViewGroup)layout.findViewById(R.id.id_custom_view);
	
	title = (TextView)layout.findViewById(R.id.id_title);
	content = (TextView)layout.findViewById(R.id.id_content_text);
	button_bar = (LinearLayout)layout.findViewById(R.id.bar_button);
	positive = (Button)layout.findViewById(R.id.button_positive);
	negative = (Button)layout.findViewById(R.id.button_negative);
	scroll = (ScrollView)layout.findViewById(R.id.id_scroll);
	list = (ListView)layout.findViewById(R.id.id_list);
	recycler = (RecyclerView)layout.findViewById(R.id.id_recycler);
	
	builder = new AlertDialog.Builder(context)
	    .setView(layout);

	dialog = builder.create();
	dialog.show();
}
 
Example 23
Project: Plus1s   File: LostViewActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lost_view);

    final TextView lost_view_back = (TextView) findViewById(R.id.lost_view_back);
    lost_view_list = (ListView) findViewById(R.id.lost_view_list);
    final Animation fade_in_anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in);
    lost_view_list.setAnimation(fade_in_anim);
    ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, displayLostItem());
    lost_view_list.setAdapter(adapter);
    lost_view_back.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            goToMain();
        }
    });
}
 
Example 24
Project: iosched-reader   File: CollectionView.java   View source code 6 votes vote down vote up
public CollectionView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setAdapter(new MyListAdapter());
    setDivider(null);
    setDividerHeight(0);
    setItemsCanFocus(false);
    setChoiceMode(ListView.CHOICE_MODE_NONE);
    setSelector(android.R.color.transparent);

    if (attrs != null) {
        final TypedArray xmlArgs = context.obtainStyledAttributes(attrs,
                R.styleable.CollectionView, defStyle, 0);
        mInternalPadding = xmlArgs.getDimensionPixelSize(
                R.styleable.CollectionView_internalPadding, 0);
        mContentTopClearance = xmlArgs.getDimensionPixelSize(
                R.styleable.CollectionView_contentTopClearance, 0);
        xmlArgs.recycle();
    }
}
 
Example 25
Project: polling-station-app   File: TransactionHistoryActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transaction_history);

    Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(appBar);
    Util.setupAppBar(appBar, this);
    ListView transactionList = (ListView) findViewById(R.id.transaction_list);

    // create a transaction history array with all the transactions and add them to the list
    ArrayList<TransactionHistoryItem> transactionHistory = new ArrayList<>();
    adapter = new TransactionsAdapter(this, transactionHistory);
    transactionList.setAdapter(adapter);

    // Load transactions in separate thread since this can take a while.
    HandlerThread thread = new HandlerThread("transactions");
    thread.start();
    new Handler(thread.getLooper()).post(loadTransactions);
}
 
Example 26
Project: eyeRS   File: ShareActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SettingUtilities.onActivityCreateSetTheme(this);
    setContentView(R.layout.activity_share);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ArrayList<ItemLabel> items = new ArrayList<>();

    for (ItemLabel category : EyeRS.getCategoriesList(this)) {
        for (ItemWrapper item : EyeRS.getItems(category.getName(), this)) {
            items.add(new ItemLabel(item.getName(), item.getImage(), ""));
        }
    }

    LabelAdapter adapter = new LabelAdapter(this, items);

    listView = (ListView) findViewById(R.id.listView);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(this);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Toast.makeText(this, "Please select the item you wish to share", Toast.LENGTH_LONG).show();
}
 
Example 27
Project: Matrix-Calculator-for-Android   File: TraceFragment.java   View source code 5 votes vote down vote up
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    ProgressDialog progressDialog = new ProgressDialog(getContext());
    progressDialog.setMessage(getString(R.string.Calculating));
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(true);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.show();
    RunToGetTrace(position, progressDialog);
}
 
Example 28
Project: AC2RD   File: Filters.java   View source code 5 votes vote down vote up
public boolean setCursorAdapter()
  {
  	try
{
   	startManagingCursor(cursor);
	
	listView = (ListView) findViewById(android.R.id.list);
	
	simpleCursorAdapter = new SimpleCursorAdapter(this, R.layout.filter, cursor, from, to);
      
	simpleCursorAdapter.setViewBinder(new ViewBinder()
	{
	    public boolean setViewValue(View aView, Cursor aCursor, int aColumnIndex)
	    {
	    	return setFilterViewValue(aView, aCursor, aColumnIndex);
	    }
	});
    	
	listView.setAdapter(simpleCursorAdapter);
	
   	return true;
}
catch (Exception e)
{
	return false;
}
  }
 
Example 29
Project: Android_RuuvitagScannner   File: ListActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);
    ruuvitagArrayList = new ArrayList<>();
    settings = PreferenceManager.getDefaultSharedPreferences(this);

    handler = new DBHandler(getApplicationContext());
    db = handler.getReadableDatabase();

    cursor = db.rawQuery("SELECT * FROM " + DBContract.RuuvitagDB.TABLE_NAME, null);
    beaconListView = (ListView)findViewById(R.id.listView);
    adapter = new listAdapter(ruuvitagArrayList, this);
    beaconListView.setAdapter(adapter);

    savedTags = getSharedPreferences("saved_tags", MODE_PRIVATE);
    gson = new Gson();

    beaconListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Intent intent = new Intent(ListActivity.this, ScannerService.class);
            Ruuvitag temp = (Ruuvitag) adapterView.getItemAtPosition(i);
            intent.putExtra("favorite", temp);
            startService(intent);
            finish();
        }
    });
}
 
Example 30
Project: InstagramManager-Android   File: FollowActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_follow);

    list.add(new Follow("A","B",""));
    list.add(new Follow("AB","BC",""));

    ListAdapter adapter=new ListAdapter();
    listView=(ListView)findViewById(R.id.list);
    listView.setAdapter(adapter);

}
 
Example 31
Project: buildAPKsApps   File: BarrageList.java   View source code 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    setContentView(R.layout.barrage_list);
    ListView listView = getListView();
    LayoutInflater inflater = LayoutInflater.from(this);
    BarrageHeaderView headerView = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    headerView.bind(getString(R.string.menu_new_barrage), getString(R.string.create_new_barrage));
    listView.addHeaderView(headerView, null, true);
    
    //UI Preview
    /*BarrageHeaderView item1 = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    item1.bind(this, new BarrageHeader("Testing 1, 2, 3...", BarrageHeader.STATUS_RUNNING, 43, 12));
    listView.addHeaderView(item1, null, true);
    BarrageHeaderView item4 = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    item4.bind(this, new BarrageHeader("Another Barrage", BarrageHeader.STATUS_PAUSED, 123, 64));
    listView.addHeaderView(item4, null, true);
    BarrageHeaderView item2 = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    item2.bind(this, new BarrageHeader("Pie Day", BarrageHeader.STATUS_QUEUED, 43, 12));
    listView.addHeaderView(item2, null, true);
    BarrageHeaderView item3 = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    item3.bind(this, new BarrageHeader("Some Name", BarrageHeader.STATUS_DRAFT, 160, 12));
    listView.addHeaderView(item3, null, true);*/
    
    setListAdapter(new BarrageListAdapter(this, null, true));
    
    if (savedInstanceState != null) {
    	//do something
    }
}
 
Example 32
Project: WarningSystemWeather-Android-App   File: ListFragment.java   View source code 5 votes vote down vote up
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    if (mListAsync.mWarningses == null) {
    } else {
        String url = mListAsync.mWarningses[position].getLink();
        OnRecipeSelectedInterface listener = (OnRecipeSelectedInterface) getActivity();
        listener.onListRecipeSelected(position, url);
    }
}
 
Example 33
Project: Renrentou   File: CitySelectFragment.java   View source code 5 votes vote down vote up
private void initProvince(){
    provinceListView = (ListView)popupView.findViewById(R.id.province_list);
    provinceAdapter = new ProvinceAdapter(getActivity());
    provinceListView.setAdapter(provinceAdapter);
    provinceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Province province = getDefaultProvince();
            if(i != 0){
                province = provinceList.get(i-1);

            }else{

            }
            if(!currentProvince.getAreaId().equals(province.getAreaId())){
                currentProvince = province;
                cityList = province.getCities();
                currentCity = getDefaultCity();
                countyList.clear();
                currentCounty = getDefaultCounty();
                provinceAdapter.notifyDataSetChanged();
                cityAdapter.notifyDataSetChanged();
                countyAdapter.notifyDataSetChanged();
            }
        }
    });
}
 
Example 34
Project: Misc   File: CallHistoryActivity.java   View source code 5 votes vote down vote up
@Override
protected void onListItemClick(ListView lv, View view, int position, long
        id) {
    super.onListItemClick(lv, view, position, id);
    // Save the position when starting the activity
    mCurrentPosition = position;
    mCurrentId = id;
    mIncrement = 0;
    displayCall();
}
 
Example 35
Project: UnversityFinance   File: NoticeListActivity.java   View source code 5 votes vote down vote up
private void initView() {
    mActionBarTitle.setText(R.string.title_notice_list);

    mListView = (ListView) findViewById(R.id.list_view);
    mListView.setOnItemClickListener(this);

    mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    mRefreshLayout.setColorSchemeResources(R.color.colorPrimaryDark);
    mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshList();
        }
    });
}
 
Example 36
Project: XERUNG   File: Profession.java   View source code 5 votes vote down vote up
private void findViewids(View view) {
    this.view = view;
    listview = (ListView)view.findViewById(R.id.lvList);
    listview1 = (ListView)view.findViewById(R.id.lvList1);
    layMain = (LinearLayout)view.findViewById(R.id.layMain);
    txtnorecord = (TextView)view.findViewById(R.id.txtnorecord);
    relProgress = (RelativeLayout)view.findViewById(R.id.layProgressresult);
}
 
Example 37
Project: iosched-reader   File: MapInfoFragment.java   View source code 5 votes vote down vote up
@Nullable
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState, int layout) {
    View root = inflater.inflate(layout, container, false);

    mTitle = (TextView) root.findViewById(R.id.map_info_title);
    mSubtitle = (TextView) root.findViewById(R.id.map_info_subtitle);
    mIcon = (ImageView) root.findViewById(R.id.map_info_icon);
    mIcon.setColorFilter(getResources().getColor(R.color.my_schedule_icon_default));
    mList = (ListView) root.findViewById(R.id.map_info_list);
    mList.setOnItemClickListener(mListClickListener);

    return root;
}
 
Example 38
Project: Android-DFU-App   File: UARTLogFragment.java   View source code 5 votes vote down vote up
@Override
public void onSaveInstanceState(final Bundle outState) {
	super.onSaveInstanceState(outState);

	// Save the last log list view scroll position
	final ListView list = getListView();
	final boolean scrolledToBottom = list.getCount() > 0 && list.getLastVisiblePosition() == list.getCount() - 1;
	outState.putInt(SIS_LOG_SCROLL_POSITION, scrolledToBottom ? LOG_SCROLLED_TO_BOTTOM : list.getFirstVisiblePosition());
}
 
Example 39
Project: rental-calc   File: PropertiesListActivityTest.java   View source code 5 votes vote down vote up
@Test
public void clickPropertyLaunchesActivity()
{
    db.insertProperty(new Property());
    ActivityController controller = Robolectric.buildActivity(PropertiesListActivity.class).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();

    ListView list = (ListView)activity.findViewById(R.id.list);
    ShadowListView shadowList = shadowOf(list);

    shadowList.populateItems();

    assertEquals(1, list.getCount());
    shadowList.performItemClick(0);

    assertTrue(activity.isFinishing() == false);

    Intent next = shadowOf(activity).getNextStartedActivity();

    ComponentName componentName = next.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals("protect.rentalcalc/.PropertyOverviewActivity", name);

    Bundle extras = next.getExtras();
    assertNotNull(extras);
    assertTrue(extras.containsKey("id"));
    assertEquals(DatabaseTestHelper.FIRST_ID, extras.getLong("id"));
}
 
Example 40
Project: android-app-aam   File: FragmentFriends.java   View source code 5 votes vote down vote up
private void populateFriendList(View rootView) {
    // Construct the data source
    ArrayList<Friend> arrayOfUsers = Friend.getFriends();
    // Create the adapter to convert the array to views
    CustomFriendAdapter adapter = new CustomFriendAdapter (getActivity(), arrayOfUsers);
    // Attach the adapter to a ListView
    ListView listView = (ListView) rootView.findViewById (R.id.lvFriends);
    listView.setAdapter(adapter);
}