List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.mifos.mifosxdroid.online.LoanRepaymentFragment.java
public void inflateUI() { showProgress(false);//from w w w . j av a 2 s.com tv_clientName.setText(clientName); tv_loanProductShortName.setText(loanProductName); tv_loanAccountNumber.setText(loanAccountNumber); tv_inArrears.setText(String.valueOf(amountInArrears)); //Setup Form with Default Values et_amount.setText("0.0"); et_amount.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { try { tv_total.setText(String.valueOf(calculateTotal())); } catch (NumberFormatException nfe) { et_amount.setText("0"); } finally { tv_total.setText(String.valueOf(calculateTotal())); } } @Override public void afterTextChanged(Editable editable) { } }); et_additionalPayment.setText("0.0"); et_additionalPayment.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { try { tv_total.setText(String.valueOf(calculateTotal())); } catch (NumberFormatException nfe) { et_additionalPayment.setText("0"); } finally { tv_total.setText(String.valueOf(calculateTotal())); } } @Override public void afterTextChanged(Editable editable) { } }); et_fees.setText("0.0"); et_fees.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { try { tv_total.setText(String.valueOf(calculateTotal())); } catch (NumberFormatException nfe) { et_fees.setText("0"); } finally { tv_total.setText(String.valueOf(calculateTotal())); } } @Override public void afterTextChanged(Editable editable) { } }); inflateRepaymentDate(); inflatePaymentOptions(); tv_total.setText(String.valueOf(calculateTotal())); }
From source file:com.mattprecious.prioritysms.fragment.ProfileDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_profile_detail, container, false); ButterKnife.inject(this, rootView); callbacks.onNameUpdated(profile.getName()); nameContainer.setVisibility((profile.getName() == null) ? View.VISIBLE : View.GONE); nameText.setText(profile.getName()); nameText.setOnFocusChangeListener(new OnFocusChangeListener() { @Override//w w w . j a va 2 s . co m public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { validateName(); } } }); nameText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { callbacks.onNameUpdated(s.toString()); } }); closeRenameButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { closeRename(); } }); pager.setAdapter(pagerAdapter); titleIndicator.setViewPager(pager); return rootView; }
From source file:com.awt.supark.EditCar.java
@Nullable @Override/* www . j a v a 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { view = inflater.inflate(R.layout.edit_car, container, false); addCarButton = (Button) view.findViewById(R.id.DoneButton); deleteButton = (Button) view.findViewById(R.id.DeleteButton); cancelButton = (Button) view.findViewById(R.id.cancelButton); carName = (EditText) view.findViewById(R.id.carName); carLicense = (EditText) view.findViewById(R.id.carLicense); txtCity = (TextView) view.findViewById(R.id.city); txtNum = (TextView) view.findViewById(R.id.number); radioNewSrb = (RadioButton) view.findViewById(R.id.radioNewSrb); radioGeneric = (RadioButton) view.findViewById(R.id.radioGeneric); radioLicenseGroup = (RadioGroup) view.findViewById(R.id.radioLicenseGroup); licensePlate = (LinearLayout) view.findViewById(R.id.licensePlate); licenseNum = ""; context = getContext(); // Setting the custom font Typeface licenseFont = Typeface.createFromAsset(getContext().getAssets(), "fonts/LicensePlate.ttf"); txtCity.setTypeface(licenseFont); txtNum.setTypeface(licenseFont); db = SQLiteDatabase.openDatabase(getContext().getFilesDir().getPath() + "/carDB.db", null, SQLiteDatabase.CREATE_IF_NECESSARY); final Bundle b = getArguments(); if (b.getInt("editid") != -1) { editid = b.getInt("editid"); Cursor d = db.rawQuery("SELECT * FROM cars WHERE car_id = " + editid, null); d.moveToFirst(); carName.setText(d.getString(d.getColumnIndex("car_name"))); licenseNum = d.getString(d.getColumnIndex("car_license")); carLicense.setText(licenseNum); if (d.getInt(d.getColumnIndex("isgeneric")) == 0) { radioNewSrb.setChecked(true); radioGeneric.setChecked(false); radioListener(); } else { radioGeneric.setChecked(true); radioNewSrb.setChecked(false); radioListener(); } deleteButton.setVisibility(View.VISIBLE); if (isCarParked(editid)) { deleteButton.setEnabled(false); } TextView text = (TextView) view.findViewById(R.id.text1); text.setText(context.getResources().getString(R.string.edit_car)); d.close(); } else { radioNewSrb.setChecked(true); radioListener(); } addCarButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (editid == -1) { addCar(v); } else { editCar(v); } } }); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDeleteQuestionDialog("", getResources().getString(R.string.are_you_sure), v); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ((MainActivity) context).openCarFragment(null, true); } }); // Filters the emojis and other unwanted characters filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { if (!Character.isLetterOrDigit(source.charAt(i))) { return ""; } } return null; } }; carName.setFilters(new InputFilter[] { filter }); //carLicense.setFilters(new InputFilter[] { filter }); // License number filler carLicense.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { licenseNum = charSequence.toString(); updateLicensePlate(charSequence); } @Override public void afterTextChanged(Editable editable) { } }); radioLicenseGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int i) { radioListener(); } }); return view; }
From source file:com.activiti.android.ui.fragments.form.EditTextDialogFragment.java
@Override public void onStart() { String value = null;//from www . j a va2 s . c o m if (getArguments() != null) { value = getArguments().getString(ARGUMENT_VALUE); hintId = getArguments().getInt(ARGUMENT_HINT_ID); notNull = getArguments().getBoolean(ARGUMENT_EMPTY); singleLine = getArguments().getBoolean(ARGUMENT_SINGLE_LINE); } super.onStart(); if (getDialog() != null) { et = ((EditText) getDialog().getWindow().findViewById(R.id.text_value)); if (singleLine) { et.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_CLASS_TEXT); et.setSingleLine(true); et.setMinLines(1); et.setMaxLines(1); et.setLines(1); } et.setText(value); if (hintId != 0) { et.setHint(hintId); } et.setSelection(et.getText().length()); if (notNull) { et.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { if (s.length() == 0) { ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(false); // ((MaterialDialog)getDialog()).getActionButton(DialogAction.POSITIVE).setBackgroundColor(getResources().getColor(R.color.primary_background)); } else { ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(true); // ((MaterialDialog)getDialog()).getActionButton(DialogAction.POSITIVE).setBackgroundColor(getResources().getColor(R.color.primary)); // backField.setBackgroundColor(getResources().getColor(R.color.primary)); } } }); } UIUtils.showKeyboard(getActivity(), et); } }
From source file:com.google.android.apps.forscience.whistlepunk.project.experiment.UpdateExperimentFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_update_experiment, container, false); mExperimentTitle = (EditText) view.findViewById(R.id.experiment_title); mExperimentDescription = (EditText) view.findViewById(R.id.experiment_description); mExperimentTitle.addTextChangedListener(new TextWatcher() { @Override//from w w w .j a v a2 s . co m public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (mExperiment == null) { return; } if (!s.toString().equals(mExperiment.getTitle())) { mExperiment.setTitle(s.toString().trim()); saveExperiment(); mWasEdited = true; } } @Override public void afterTextChanged(Editable s) { } }); mExperimentDescription.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (mExperiment == null) { return; } if (!s.toString().equals(mExperiment.getDescription())) { mExperiment.setDescription(s.toString().trim()); saveExperiment(); mWasEdited = true; } } @Override public void afterTextChanged(Editable s) { } }); return view; }
From source file:ca.mymenuapp.ui.activities.MainActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); inflateView(R.layout.activity_main); locationProvider.getLastKnownLocation().subscribe(new Action1<Location>() { @Override// w w w .j a v a 2 s . c o m public void call(Location location) { lastLatLng = new LatLng(location.getLatitude(), location.getLongitude()); myMenuDatabase.getNearbyRestaurants(location.getLatitude(), location.getLongitude(), new EndlessObserver<List<Restaurant>>() { @Override public void onNext(List<Restaurant> restaurantList) { restaurants = restaurantList; bus.post(new OnRestaurantListAvailableEvent(restaurantList)); } }); } }); setupTabs(savedInstanceState != null ? savedInstanceState.getInt("tab", 0) : 0); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.restaraunt_grid_container, new RestaurantGridFragment()).commit(); } // start drawer in open state drawerLayout.openDrawer(drawer); // allow user to toggle drawer with the action bar drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; drawerLayout.setDrawerListener(drawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); searchField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { searchRestaurantsInMemory(s.toString()); } @Override public void afterTextChanged(Editable s) { } }); }
From source file:com.bdcorps.videonews.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent();//from ww w. j a v a 2 s. c o m topicCode = intent.getStringExtra("topicCode"); //if it's a string you stored. //CCT Connection mConnection = new CustomTabsServiceConnection() { @Override public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient customTabsClient) { mClient = customTabsClient; mCustomTabsSession = getSession(); mClient.warmup(0); } @Override public void onServiceDisconnected(ComponentName componentName) { mClient = null; mCustomTabsSession = null; } }; //Bind CCT Service String packageName = "com.android.chrome"; CustomTabsClient.bindCustomTabsService(this, packageName, mConnection); text = (TextView) findViewById(R.id.textview); img = (ImageView) findViewById(R.id.imageview); titleTextView = (TextView) findViewById(R.id.title_text_view); mTts = new TextToSpeech(this, this); Button b1 = (Button) findViewById(R.id.button); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { grabnews(topicCode); } }); Button b2 = (Button) findViewById(R.id.button2); b2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { speak(text.getText().toString()); } }); Button b3 = (Button) findViewById(R.id.button3); b3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { article++; grabnews(topicCode); } }); text.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { Log.i("SSS", "text on board is =" + editable.toString()); speak(text.getText().toString()); } }); }
From source file:com.feytuo.chat.activity.ChatHistoryFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); errorItem = (RelativeLayout) getView().findViewById(R.id.rl_error_item); errorText = (TextView) errorItem.findViewById(R.id.tv_connect_errormsg); // contact list contactList = App.getInstance().getContactList(); listView = (ListView) getView().findViewById(R.id.list); adapter = new ChatHistoryAdapter(getActivity(), 1, loadUsersWithRecentChat()); // adapter//from w w w . j av a 2s.c om listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EMContact emContact = adapter.getItem(position); if (adapter.getItem(position).getUsername().equals(App.getInstance().getUserName())) Toast.makeText(getActivity(), "??", 0).show(); else { // ?? Intent intent = new Intent(getActivity(), ChatActivity.class); if (emContact instanceof EMGroup) { //it is group chat intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP); intent.putExtra("groupId", ((EMGroup) emContact).getGroupId()); } else { //it is single chat intent.putExtra("userId", emContact.getUsername()); } startActivity(intent); } } }); // ?? registerForContextMenu(listView); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); // ? query = (EditText) getView().findViewById(R.id.query); // ?button clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); } }); }
From source file:com.misczak.joinmybridge.BridgeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_bridge, parent, false); mBridgeName = (EditText) v.findViewById(R.id.bridge_name); if (mBridgeId != null && !mBridge.getBridgeName().equals(DEFAULT_FIELD)) { mBridgeName.setText(mBridge.getBridgeName()); } else if (getArguments().getSerializable(EXTRA_BRIDGE_NAME) != null) { mBridgeNameString = (getArguments().getSerializable(EXTRA_BRIDGE_NAME)).toString(); if (mBridgeNameString.length() > MAX_NAME_LENGTH) { mBridgeNameString = mBridgeNameString.substring(0, MAX_NAME_LENGTH); }//from ww w . j a v a2 s .c o m mBridgeName.setText(mBridgeNameString); } mBridgeName.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence c, int start, int before, int after) { mBridgeNameString = c.toString(); if (mBridgeNameString.equals("")) { mBridgeNameString = DEFAULT_FIELD; } } public void beforeTextChanged(CharSequence c, int start, int count, int after) { } public void afterTextChanged(Editable c) { } }); mBridgeNumber = (EditText) v.findViewById(R.id.bridge_number); if (mBridgeId != null && !mBridge.getBridgeNumber().equals(DEFAULT_FIELD)) { mBridgeNumber.setText(mBridge.getBridgeNumber()); } else if (getArguments().getSerializable(EXTRA_BRIDGE_NUMBER) != null) { mBridgeNumberString = (getArguments().getSerializable(EXTRA_BRIDGE_NUMBER).toString()); mBridgeNumber.setText(mBridgeNumberString); } mBridgeNumber.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence c, int start, int before, int after) { mBridgeNumberString = c.toString(); if (mBridgeNumberString.equals("")) { mBridgeNumberString = DEFAULT_FIELD; } } public void beforeTextChanged(CharSequence c, int start, int count, int after) { //Left blank for now } public void afterTextChanged(Editable c) { } }); mHostCode = (EditText) v.findViewById(R.id.host_code); if (mBridgeId != null && !mBridge.getHostCode().equals(DEFAULT_FIELD)) { mHostCode.setText(mBridge.getHostCode()); } else if (getArguments().getSerializable(EXTRA_HOST_CODE) != null) { mHostCodeString = getArguments().getSerializable(EXTRA_HOST_CODE).toString(); mHostCode.setText(mHostCodeString); } mHostCode.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence c, int start, int before, int after) { mHostCodeString = c.toString(); if (mHostCodeString.equals("")) { mHostCodeString = DEFAULT_FIELD; } } public void beforeTextChanged(CharSequence c, int start, int count, int after) { //Left blank for now } public void afterTextChanged(Editable c) { } }); mParticipantCode = (EditText) v.findViewById(R.id.participant_code); if (mBridgeId != null && !mBridge.getParticipantCode().equals(DEFAULT_FIELD)) { mParticipantCode.setText(mBridge.getParticipantCode()); } else if (getArguments().getSerializable(EXTRA_PARTICIPANT_CODE) != null) { mParticipantCodeString = getArguments().getSerializable(EXTRA_PARTICIPANT_CODE).toString(); mParticipantCode.setText(mParticipantCodeString); } mParticipantCode.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence c, int start, int before, int after) { mParticipantCodeString = c.toString(); if (mParticipantCodeString.equals("")) { mParticipantCodeString = DEFAULT_FIELD; } } public void beforeTextChanged(CharSequence c, int start, int count, int after) { } public void afterTextChanged(Editable c) { } }); mFirstTone = (Spinner) v.findViewById(R.id.bridgeFirstToneKey); if (mBridgeId != null && mBridge.getFirstTone() != null) { mFirstTone.setSelection(getSpinnerIndex(mFirstTone, mBridge.getFirstTone())); } else if (getArguments().getSerializable(EXTRA_FIRST_TONE) != null) { mFirstTone.setSelection( getSpinnerIndex(mFirstTone, (String) getArguments().getSerializable(EXTRA_FIRST_TONE))); } mFirstTone.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mFirstToneString = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> parent) { mFirstToneString = DEFAULT_TONE; } }); mSecondTone = (Spinner) v.findViewById(R.id.bridgeSecondToneKey); if (mBridgeId != null && mBridge.getSecondTone() != null) { mSecondTone.setSelection(getSpinnerIndex(mSecondTone, mBridge.getSecondTone())); } else if (getArguments().getSerializable(EXTRA_SECOND_TONE) != null) { mSecondTone.setSelection( getSpinnerIndex(mSecondTone, (String) getArguments().getSerializable(EXTRA_SECOND_TONE))); } mSecondTone.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mSecondToneString = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> parent) { mSecondToneString = DEFAULT_TONE; } }); mCallOrder = (Spinner) v.findViewById(R.id.callOrderSpinner); if (mBridgeId != null && mBridge.getCallOrder() != null) { mCallOrder.setSelection(getSpinnerIndex(mCallOrder, mBridge.getCallOrder())); } mCallOrder.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mCallOrderString = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> parent) { mCallOrderString = DEFAULT_ORDER; } }); mDialingPause = (Slider) v.findViewById(R.id.pauseSlider); mPauseLabel = (TextView) v.findViewById(R.id.pauseSliderLabel); if (mBridgeId != null && (Integer) mBridge.getDialingPause() != null) { Log.d(TAG, "Pause passed null check" + mBridge.getDialingPause()); mDialingPauseNumber = mBridge.getDialingPause(); } else { Log.d(TAG, "Pause or bridge is null"); mDialingPauseNumber = DEFAULT_PAUSE; } mDialingPause.setValue(mDialingPauseNumber); mPauseLabel.setText("Dialing Pause (" + mDialingPauseNumber + " seconds)"); mDialingPause.setOnValueChangedListener(new Slider.OnValueChangedListener() { @Override public void onValueChanged(int i) { mDialingPauseNumber = i; mPauseLabel.setText("Dialing Pause (" + mDialingPauseNumber + " seconds)"); } }); return v; }
From source file:it.uniroma2.foundme.studente.FollowCourseActivity.java
public static void populateView(String[] result) { courses = new String[result.length]; System.arraycopy(result, 0, courses, 0, result.length); List<Map<String, String>> data = new ArrayList<Map<String, String>>(); for (int i = 0; i < result.length; i++) { Map<String, String> datum = new HashMap<String, String>(2); if (i == 0 && result[0].equalsIgnoreCase(Variables_it.NO_COURSE)) { datum.put(Variables_it.COURSE, result[0]); datum.put(Variables_it.PROF, ""); data.add(datum);/*w ww . j av a 2s . c o m*/ break; } else { String[] items = result[i].split(","); String ap = items[0] + items[1]; datum.put(Variables_it.COURSE, ap); datum.put(Variables_it.PROF, items[2]); data.add(datum); } } //creo l'adapter final SimpleAdapter adapter = new SimpleAdapter(context, data, android.R.layout.simple_list_item_2, new String[] { Variables_it.COURSE, Variables_it.PROF }, new int[] { android.R.id.text1, android.R.id.text2 }); lvTuttiCorsi.setAdapter(adapter); lvTuttiCorsi.setTextFilterEnabled(true); swipeFollow.setColorSchemeColors(0xff429874, 0xffffffff, 0xff429874, 0xffffffff); swipeFollow.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { swipeFollow.setRefreshing(true); (new Handler()).postDelayed(new Runnable() { @Override public void run() { swipeFollow.setRefreshing(false); try { getCourse(false); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }, 3000); } }); lvTuttiCorsi.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!courses[position].equalsIgnoreCase(Variables_it.NO_COURSE)) alertMessage(courses[position]); } }); lvTuttiCorsi.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem == 0) swipeFollow.setEnabled(true); else swipeFollow.setEnabled(false); } }); etFilter.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); }