List of usage examples for android.widget TextView setHintTextColor
public final void setHintTextColor(ColorStateList colors)
From source file:com.bt.download.android.gui.util.UIUtils.java
/** * Android devices with SDK below target=11 do not support textView.setAlpha(). * This is a work around. //from w w w . j a v a2 s . c o m * @param v - the text view * @param alpha - a value from 0 to 255. (0=transparent, 255=fully visible) */ public static void setTextViewAlpha(TextView v, int alpha) { v.setTextColor(v.getTextColors().withAlpha(alpha)); v.setHintTextColor(v.getHintTextColors().withAlpha(alpha)); v.setLinkTextColor(v.getLinkTextColors().withAlpha(alpha)); Drawable[] compoundDrawables = v.getCompoundDrawables(); for (int i = 0; i < compoundDrawables.length; i++) { Drawable d = compoundDrawables[i]; if (d != null) { d.setAlpha(alpha); } } }
From source file:com.example.android.movies.app.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();//from w w w . j a v a 2s . com //getMenuInflater().inflate(R.menu.main, menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); MenuItem searchItem = menu.findItem(R.id.search); android.support.v7.widget.SearchView searchView = (android.support.v7.widget.SearchView) MenuItemCompat .getActionView(searchItem); searchView.setQueryHint("Find movies..."); int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_plate", null, null); View searchPlate = searchView.findViewById(searchPlateId); if (searchPlate != null) { searchPlate.setBackgroundColor(Color.DKGRAY); int searchTextId = searchPlate.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); TextView searchText = (TextView) searchPlate.findViewById(searchTextId); if (searchText != null) { searchText.setTextColor(Color.WHITE); searchText.setHintTextColor(Color.WHITE); } } SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { public boolean onQueryTextChange(String newText) { return true; } public boolean onQueryTextSubmit(String query) { SearchFragment fragmentS1 = new SearchFragment(); Bundle bundle = new Bundle(); bundle.putString("search", query); fragmentS1.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.container, fragmentS1).commit(); return true; } }; searchView.setOnQueryTextListener(queryTextListener); searchView.setIconifiedByDefault(false); return true; }
From source file:ph.devcon.android.attendee.AttendeesFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); // Inflate the menu; this adds items to the action bar if it is present. getActivity().getMenuInflater().inflate(R.menu.attendee, menu); MenuItem menuItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem); searchView/* w ww.j a v a 2 s . c om*/ .setQueryHint(Html.fromHtml("<font color = #808080>Find by name, address, company, etc..</font>")); int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_plate", null, null); View searchPlate = searchView.findViewById(searchPlateId); if (searchPlate != null) { searchPlate.setBackgroundColor(Color.DKGRAY); int searchTextId = searchPlate.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); TextView searchText = (TextView) searchPlate.findViewById(searchTextId); if (searchText != null) { searchText.setTextColor(Color.DKGRAY); searchText.setHintTextColor(Color.DKGRAY); } } MenuItemCompat.setOnActionExpandListener(menuItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { return true; } }); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { search(s); lastQuery = s; return false; } @Override public boolean onQueryTextChange(String s) { if (!Util.isNullOrEmpty(s)) { search(s); lastQuery = s; } return false; } }); }
From source file:com.numenta.taurus.instance.InstanceListActivity.java
private void configureSearchView(@NonNull final SearchView searchView) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); // Handle query events searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override// w ww . ja v a 2 s .co m public boolean onQueryTextSubmit(String query) { // Hide Keyboard on submit InputMethodManager imm = (InputMethodManager) searchView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0); } return true; } @Override public boolean onQueryTextChange(String newText) { // Filter list as the user types _listFragment.applyFilter(newText); return true; } }); // FIXME: Android does not support styling the search view across all versions. // For now, "peek" into internal API to make the appropriate changes to the SearchView. // In the future we should use the official android API to customize the SearchView widget. // See android.R.layout.search_view for the layout we are "peeking". It is no guarantee it // will work on all public android versions and/or OEM customizations. // This HACK is only valid for the POC phase. We should find a better solution before releasing Resources resources = searchView.getResources(); // Style search box and text int searchPlateId = resources.getIdentifier("android:id/search_plate", null, null); View searchPlate = searchView.findViewById(searchPlateId); if (searchPlate != null) { int searchTextId = resources.getIdentifier("android:id/search_src_text", null, null); TextView searchText = (TextView) searchPlate.findViewById(searchTextId); if (searchText != null) { searchPlate.setBackgroundResource(android.R.drawable.editbox_background); searchText.setPadding(5, 0, 0, 0); searchText.setTextColor(Color.BLACK); searchText.setHintTextColor(Color.LTGRAY); } } }
From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java
/** * Invoked when the options menu is created. Creates our own options menu * from the corresponding xml./* w w w . jav a2 s . c o m*/ * * @param menu the options menu */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { super.onCreateOptionsMenu(menu, menuInflater); Activity activity = getActivity(); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE); this.searchItem = menu.findItem(R.id.search); // OnActionExpandListener not supported prior API 14 if (AndroidUtils.hasAPI(14)) { searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @Override public boolean onMenuItemActionCollapse(MenuItem item) { filterContactList(""); return true; // Return true to collapse action view } public boolean onMenuItemActionExpand(MenuItem item) { return true; // Return true to expand action view } }); } if (AndroidUtils.hasAPI(11)) { SearchView searchView = (SearchView) searchItem.getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName())); int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); TextView textView = (TextView) searchView.findViewById(id); textView.setTextColor(getResources().getColor(R.color.white)); textView.setHintTextColor(getResources().getColor(R.color.white)); bindSearchListener(); } }
From source file:edu.sfsu.csc780.chathub.ui.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DesignUtils.applyColorfulTheme(this); setContentView(R.layout.activity_main); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // Set default username is anonymous. mUsername = ANONYMOUS;//from ww w . j av a 2s. c o m //Initialize Auth mAuth = FirebaseAuth.getInstance(); mUser = mAuth.getCurrentUser(); if (mUser == null) { startActivity(new Intent(this, SignInActivity.class)); finish(); return; } else { mUsername = mUser.getDisplayName(); if (mUser.getPhotoUrl() != null) { mPhotoUrl = mUser.getPhotoUrl().toString(); } } AudioUtil.startAudioListener(this); mSinchClient = Sinch.getSinchClientBuilder().context(getApplicationContext()) .applicationKey(APIKeys.SINCH_API_KEY).applicationSecret(APIKeys.SINCH_APP_SECRET) .environmentHost("sandbox.sinch.com") .userId(UserUtil.parseUsername(mSharedPreferences.getString("username", "anonymous"))).build(); mSinchClient.setSupportCalling(true); mCurrentChannel = mSharedPreferences.getString("currentChannel", "general"); mCurrChanTextView = (TextView) findViewById(R.id.currentChannelName); mCurrChanTextView.setText(ChannelUtil.getChannelDisplayName(mCurrentChannel, this)); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API).build(); // Initialize ProgressBar and RecyclerView. mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView); mLinearLayoutManager = new LinearLayoutManager(this); mLinearLayoutManager.setStackFromEnd(true); mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); mChannelAdd = (RelativeLayout) findViewById(R.id.channelAdd); mToolBar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolBar); mToolBar.setTitleTextColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); mDrawerLayout.setStatusBarBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary)); mFirebaseAdapter = MessageUtil.getFirebaseAdapter(this, this, /* MessageLoadListener */ mLinearLayoutManager, mMessageRecyclerView, mImageClickListener); mMessageRecyclerView.setAdapter(mFirebaseAdapter); mProgressBar.setVisibility(ProgressBar.INVISIBLE); mMessageEditText = (EditText) findViewById(R.id.messageEditText); mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(MSG_LENGTH_LIMIT) }); mMessageEditText.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) { if (charSequence.toString().trim().length() > 0) { mSendButton.setEnabled(true); } else { mSendButton.setEnabled(false); } } @Override public void afterTextChanged(Editable editable) { } }); mSendButton = (FloatingActionButton) findViewById(R.id.sendButton); mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Send messages on click. mMessageRecyclerView.scrollToPosition(0); ChatMessage chatMessage = new ChatMessage(mMessageEditText.getText().toString(), mUsername, mPhotoUrl, mCurrentChannel); MessageUtil.send(chatMessage, MainActivity.this); mMessageEditText.setText(""); } }); mImageButton = (ImageButton) findViewById(R.id.shareImageButton); mImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pickImage(); } }); mPhotoButton = (ImageButton) findViewById(R.id.cameraButton); mPhotoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dispatchTakePhotoIntent(); } }); mLocationButton = (ImageButton) findViewById(R.id.locationButton); mLocationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { loadMap(); } }); mChannelAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this, ChannelSearchActivity.class); startActivityForResult(intent, REQUEST_NEW_CHANNEL); } }); SearchView jumpSearchView = (SearchView) findViewById(R.id.jumpSearch); int id = jumpSearchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); TextView textView = (TextView) jumpSearchView.findViewById(id); textView.setTextColor(Color.WHITE); textView.setHintTextColor(Color.WHITE); jumpSearchView.setIconified(false); jumpSearchView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(MainActivity.this, "Not implemented", Toast.LENGTH_SHORT).show(); } }); mNavRecyclerView = (RecyclerView) findViewById(R.id.navRecyclerView); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); mNavRecyclerView.setLayoutManager(linearLayoutManager); mNavRecyclerView.setAdapter(ChannelUtil.getFirebaseAdapterForUserChannelList(mChannelClickListener, mAuth.getCurrentUser().getDisplayName())); RecyclerView userListRecyclerView = (RecyclerView) findViewById(R.id.userListRecyclerView); LinearLayoutManager linearLayoutManager2 = new LinearLayoutManager(this); userListRecyclerView.setLayoutManager(linearLayoutManager2); userListRecyclerView.setAdapter(UserUtil.getFirebaseAdapterForUserList(mChannelClickListener)); Button voiceCallButton = (Button) findViewById(R.id.voiceCall); mCallProgressTextView = (TextView) findViewById(R.id.callinprogress); final AudioManager audioManager = (AudioManager) getApplicationContext() .getSystemService(Context.AUDIO_SERVICE); voiceCallButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { CallClient callClient = mSinchClient.getCallClient(); if (canCall) { call = callClient.callConference("General"); call.addCallListener(new CallListener() { @Override public void onCallProgressing(Call call) { //setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); audioManager.adjustStreamVolume(AudioManager.STREAM_VOICE_CALL, AudioManager.ADJUST_RAISE, 10); Log.d("Call", "Call progressing"); } @Override public void onCallEstablished(Call call) { setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); mCallProgressTextView.setVisibility(View.VISIBLE); Log.d("Call", "Calling now"); } @Override public void onCallEnded(Call call) { setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); Log.d("Call", "Stopped calling"); mCallProgressTextView.setVisibility(View.INVISIBLE); } @Override public void onShouldSendPushNotification(Call call, List<PushPair> list) { Log.d("Call", "Push"); } }); } } }); Button endCallButton = (Button) findViewById(R.id.endCall); endCallButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (call != null) { call.hangup(); call = null; } } }); }