Search value in a EditText - email

I have a edit box in my layout and when user press the button for Send Mailto check if the value fromEdit Box contains # and .com
layout code:
<EditText
android:id="#+id/editTextMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="10"
android:fontFamily="serif-monospace"
android:hint="Descriere"
android:inputType="textMultiLine"
android:lines="5"
android:textAlignment="center"
android:textColor="#color/white"
android:textColorHighlight="#color/white"
android:textColorHint="#color/white"
tools:layout_editor_absoluteX="22dp"
tools:layout_editor_absoluteY="162dp" />
<Button
android:id="#+id/sendBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Send"
android:focusable="true"
android:layout_marginStart="10dp"
android:background="#drawable/button_style"
android:textColor="#color/white"
/>
and java is empty I didn't try anything because I didn't know how to search the value in edit box

Related

How to display the full content of each item in ListView (Android Studio)?

I am trying to display the entire content of each item in ListView. I read other posts (1)(2), but none of them worked.
Things I tried so far:
(1) I added android:minHeight="?android:attr/listPreferredItemHeight" to TextView
(2) Just in case, I added android:minHeight="?android:attr/listPreferredItemHeight" to ListView
(3) I added android:height=wrap_content to TextView
(4) I added android:height=wrap_content to to ListView
(5) I added (1) and (3)
(6) I added (2) and (4)
(7) I added convertView.setMinimumHeight(100); in my java file
Here is my file with ListView:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FragmentNotes"
android:theme="#style/FontStyle"
android:id="#+id/fragment_note_id">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
android:orientation="vertical">
<TextView
android:id="#+id/white_background_round"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/white_background_round" />
<RelativeLayout
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/white_background_round"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp">
<TextView
android:id="#+id/title_string"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notes"
android:textColor="#color/colorPrimary"
android:textSize="45sp"
android:textStyle="bold"
android:layout_marginBottom="10sp"/>
<ImageView
android:id="#+id/title_image"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignTop="#+id/title_string"
android:layout_alignBottom="#+id/title_string"
android:layout_marginLeft="20dp"
android:layout_toEndOf="#+id/title_string"
android:background="#drawable/ic_note_english" />
</RelativeLayout>
<ImageView
android:id="#+id/button_background"
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/white_background_round"
android:layout_alignEnd="#+id/white_background_round"
android:layout_marginRight="60dp"
android:layout_marginLeft="60dp"
android:layout_below="#+id/title"
android:background="#drawable/light_background_round_english" />
<Button
android:id="#+id/btn_my_notes"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignTop="#+id/button_background"
android:layout_alignStart="#+id/button_background"
android:layout_alignBottom="#+id/button_background"
android:layout_toStartOf="#+id/centerline"
android:text="My Notes"
android:textColor="#color/colorPrimary"
android:textStyle="bold"
android:background="#android:color/transparent"
android:elevation="10dp"/>
<Button
android:id="#+id/btn_all_notes"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignTop="#+id/button_background"
android:layout_alignEnd="#+id/button_background"
android:layout_alignBottom="#+id/button_background"
android:layout_toEndOf="#+id/centerline"
android:text="All Notes"
android:textColor="#color/colorPrimary"
android:textStyle="bold"
android:background="#android:color/transparent"
android:elevation="10dp"/>
<TextView
android:id="#+id/centerline"
android:layout_width="1dp"
android:layout_height="10dp"
android:layout_alignBottom="#+id/button_background"
android:layout_centerHorizontal="true"
android:layout_below="#+id/title"
android:background="#color/colorPrimary"
android:layout_margin="5dp"
android:layout_alignTop="#+id/button_background"/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/white_background_round"
android:layout_alignLeft="#id/white_background_round"
android:layout_alignBottom="#id/white_background_round"
android:layout_below="#+id/button_background"
android:layout_margin="10sp"
android:id="#+id/list_view" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_margin="20dp"
android:layout_alignBottom="#id/white_background_round"
android:layout_alignRight="#id/white_background_round"
android:src="#drawable/ic_add_white"/>
</RelativeLayout>
</FrameLayout>
And here is my file with TextView:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/listview_item_text"
android:textColor="#color/colorPrimary"
android:text="1) When anyone brings a grain offering to the Lord, their offering is to be of the finest flour. They are to pour olive oil on it, put incense on it"
android:textSize="20dp"
android:paddingLeft="20sp"
android:paddingRight="20sp"
android:paddingTop="10sp"
android:paddingBottom="10sp"
android:textStyle="bold"
android:lineSpacingMultiplier="1.5"
android:layout_width="fill_parent"
android:singleLine="true"
android:layout_height="wrap_content"/>
Any help will be greatly appreciated.
Just in case anyone needs this answer, I found that the problem was TextView's line android:singleLine="true". I removed the line, and now I can see all contents for each item in ListView.

How do I code the red email signin button for Firebase authentication?

My Firebase app uses Google signin as well as non-Gmail signin. I've seen the little red "Sign in with email" button here, but I couldn't find a layout that shows how to code it. My login activity looks like the following:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
// Views
findViewById(R.id.signInButton).setOnClickListener(this);
findViewById(R.id.emailSignInButton).setOnClickListener(this);
// Configure Google Sign In
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
}
and here's activity_login:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/app_logo"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="#drawable/logo"/>
<TextView
android:id="#+id/welcome"
android:layout_below="#+id/app_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_centerHorizontal="true"
android:text="#string/welcome"
android:visibility="invisible"
android:textSize="20sp"
android:textStyle="bold" />
<ProgressBar
android:id="#+id/progressBar"
style="#style/Widget.AppCompat.ProgressBar"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.google.android.gms.common.SignInButton
android:id="#+id/signInButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:visibility="visible" />
<Button
android:id="#+id/emailSignInButton"
android:layout_below="#+id/signInButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/email_signin"
android:layout_centerInParent="true" />
</RelativeLayout>
</LinearLayout>
I want to replace the Button tag with something that will render the same button one gets using AuthUI.IdpConfig.EmailBuilder().build(). I don't want to use the approach given on the page I referenced above as that not only violates best principles (declare the UI in XML rather than coding it inline) but also would necessitate major changes to code that's already working.
Thanks to Frank van Puffelen's suggestion, I found the button I needed:
<com.firebase.ui.auth.util.ui.SupportVectorDrawablesButton
android:id="#+id/email_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/FirebaseUI.Button.AccountChooser.EmailButton"
android:text="#string/fui_sign_in_with_email"
tools:ignore="UnusedIds" /> <!-- Used in tests -->

how to style radio button that is on the right hand side of text

I have a radio group with three radio buttons
I put the text on the left hand side of radio button with below command
android:drawableRight="#drawable/abc_btn_radio_material"
but the default button color is black and I can't change its color using android:theme command, does anyone know how can I change the default color?
my full radio group code:
<RadioGroup
android:id="#+id/main_loading_radioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="6dp"
android:layout_marginTop="6dp"
android:checkedButton="#+id/main_wall_load"
android:orientation="vertical">
<RadioButton
android:id="#+id/main_wall_load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#null"
android:drawableRight="#drawable/abc_btn_radio_material"
android:theme="#style/MyRadioButton"
android:layout_gravity="right"
android:text="A"
android:textColor="#000000"
android:textSize="12sp"/>
<RadioButton
android:id="#+id/main_roof_load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#null"
android:layout_gravity="right"
android:drawableRight="#drawable/abc_btn_radio_material"
android:text="AA"
android:textSize="12sp"/>
<RadioButton
android:id="#+id/main_stairCase_load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#null"
android:layout_gravity="right"
android:drawableRight="#drawable/abc_btn_radio_material"
android:text="AAA"
android:textColor="#000000"
android:textSize="12sp"/>
</RadioGroup>
Try This code,
Make this file in your res/drawable
radiobutton_drawable.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/radio_uncheck" android:state_checked="false" android:state_focused="true" />
<item android:drawable="#drawable/radio_uncheck" android:state_checked="false" android:state_focused="false" />
<item android:drawable="#drawable/radio_check" android:state_checked="true" android:state_focused="true" />
<item android:drawable="#drawable/radio_check" android:state_checked="true" android:state_focused="false" />
</selector>
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="#dimen/activity_vertical_margin">
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_loading_radioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<RadioButton
android:id="#+id/main_wall_load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#android:color/transparent"
android:checked="true"
android:drawablePadding="30dp"
android:drawableRight="#drawable/radiobutton_drawable"
android:text="A"
android:textColor="#000000"
android:textSize="12sp" />
<RadioButton
android:id="#+id/main_roof_load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#android:color/transparent"
android:drawablePadding="24dp"
android:drawableRight="#drawable/radiobutton_drawable"
android:text="AA"
android:textSize="12sp" />
<RadioButton
android:id="#+id/main_stairCase_load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#android:color/transparent"
android:drawablePadding="18dp"
android:drawableRight="#drawable/radiobutton_drawable"
android:text="AAA"
android:textColor="#000000"
android:textSize="12sp" />
</RadioGroup>
</RelativeLayout>
These are the drawables which i have used for checked and unchecked state of radio button,
Hereby, i am attaching screenshot,
Hope it will help you!!!

Android Dim Background of Custom Dialog

As titled, I cannot seem to be able to dim the background of the custom dialog box I have made. Countless solutions online mention the last 3 lines of code in the first snippet below, this has made no impact on the UI of the dialog box.
See the following code:
Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog);
TextView textView = (TextView) dialog.findViewById(R.id.textView);
textView.setText("Custom Text Example");
dialog.show();
WindowManager.LayoutParams layoutParams = dialog.getWindow().getAttributes();
layoutParams.dimAmount = .7f;
dialog.getWindow().setAttributes(layoutParams);
The layout xml file for the custom dialog is as follows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/progressDialogCustom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/dialog_black"
android:orientation="horizontal"
android:padding="10dp" >
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textColor="#android:color/white"
android:text="Updating Profile . . ." />
</LinearLayout>
The #drawable/dialog_black file is as follows:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#android:color/background_dark" />
<corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
<stroke
android:width="1px"
android:color="#android:color/darker_gray" />
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
</shape>
Have you tried adding:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dimAmount is ignored unless this flag is present.

using android:layout_gravity

i am new to android development. I want to know how to use the attribute android:layout_gravity and can i use this option to position a view at center of the screen width.??
I tried the following but it's aligning at top
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Table Layout" />
<TableRow>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="Username"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:hint="username" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:hint="password"
android:inputType="textPassword" />
</TableRow>
<TableRow>
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="SAVE" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="CANCLE" />
</TableRow>
</TableLayout>
and my output is :
In Android there is
android:gravity and android:layout_gravity
android:gravity - Is used to move the content of the View or Layout to which this property is set.
android:layout_gravity - Is used to move the View or Layout itself to any position.
Here is a nice demo and explanation of how it works.
gravity and layout_gravity
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="CANCEL"
android:gravity="LEFT"
android:orientation="horizontal"
/>