get popup valus and send it to mail in android - android

i have an app which has a form values..
Title...
username...
email...
send(Button)
and this form is shown as popup window
my popup xml code is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/compose_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C0000000"
android:visibility="visible"
android:gravity="center"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:id="#+id/popup"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#f47d7d"
android:layout_gravity="center"
android:paddingLeft="20sp"
android:paddingRight="60sp"
android:paddingTop="20sp"
android:paddingBottom="20sp"
>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Popup"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/topicname"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Topic Name" />
<EditText
android:id="#+id/topiccontent"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Topic Headings" />
<EditText
android:id="#+id/usermail"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your mail" />
<Button
android:id="#+id/close"
android:layout_marginTop="10dp"
android:layout_gravity=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
</RelativeLayout>
firstly,my popup window form is not editable..please suggest something to make it editable
secondly, i want to get these values(title,username and email) and send it to specified email address on send button click.
Thanks in advance

BackgroundMail.newBuilder(getActivity())
.withUsername("Your newly created Gmail account")
.withPassword("your password")
.withMailto(email.getText().toString())
.withSubject("TEST ANDROID STUDIO")
.withBody("ELOWWWWW")
.withOnSuccessCallback(new BackgroundMail.OnSuccessCallback() {
#Override
public void onSuccess() {
//do some magic
Log.d(TAG,"MAI SENDED");
}
})
.withOnFailCallback(new BackgroundMail.OnFailCallback() {
#Override
public void onFail() {
Log.d(TAG,"MAI FAILED");
}
})
.send();
Call the above method inside your send button clicklistner
to import the library as module get it from this link https://github.com/yesidlazaro/GmailBackground

Related

How can i detect if a Card or a RecyclerView's item is selected?

i'm new to Android and i'm working on a University project, an app to take notes. I can add and delete note, but i would like to implement a classic way to delete an item: long press on it and delete it with dialogs or whatever.
This is what i have: Main Activity
I tried to click for a few seconds on the cards/notes (they are in a recycle view nested in a coordinator layout) and i saw that a background visual effect is displayed, so i think that something is already implemented.
Let me know if you need XML layout implementation or something else to answer. Thanks! :)
EDIT
requested code
CardView cardView = findViewById(R.id.cardId);
cardView.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View view) {
Toast.makeText(MainActivity.this, "long click!", Toast.LENGTH_SHORT).show();
return true;
}
});
XML Declaration of the cardview
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/touch_layout"
android:background="?attr/selectableItemBackground">
<androidx.cardview.widget.CardView
android:id="#+id/cardId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/cardStyle"
android:elevation="4dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
tools:text="title"
android:textStyle="bold"
android:textSize="20sp"
android:layout_toStartOf="#id/showText"/>
<androidx.appcompat.widget.AppCompatImageButton
android:id="#+id/showText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:src="#drawable/ic_leftarrow" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text"
android:layout_alignParentEnd="true"
android:textSize="12sp"
android:layout_marginTop="4dp"
tools:text="#string/date" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_below="#+id/title"
tools:text="message..." />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
You can use long click listener easy on recylerview
itemView.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View view) {
Log.v("LongClick: "+"LongClick");
return true;// returning true instead of false, works for me
}
});
What you see in the background is the nativen effect applied on some ItemViews by Android. For registering clicks, follow these steps:
Create the layout in the XML and assign an ID to it.
<TextView
android:id="#+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:layout_marginRight="16dp"
android:layout_alignParentEnd="true"/>
Declare and define the view (TextView in this case) by using the assigned ID:
TextView messageText;
messageText = itemView.findViewById(R.id.timestamp);
Attach Listener to register clicks:
messageText.setOnLongClickListener(new View.OnClickListener() {
#Override
public void onLongClick(View view){
// Do what you want here.
}
});

Store image as value in Android Studio

This is a code when user choose one image and will run this coding (finish()), if choose wrong image then do not run the finish() .
but i dont know how to make the image as a value , how i select the drawable a or b or c and link to this function
if(eyeDected)
{
if(detectedFrame > 25)
{
eyeDected = false;
detectedFrame = 0;
finish();
} else {
detectedFrame++;
Log.d("UNLOCK:", String.valueOf(detectedFrame));
}
} else {
eyeDected = true;
detectedFrame++;
Log.d("UNLOCK:", String.valueOf(detectedFrame));
}
I want to ask about how to store the drawble/image into value?
i'm developing a lock screen application , when user choose the correct image will execute the unlock function
This is a layout showing 3 images and give user choose one images inside a lock screen.
In the setting , i'll let user to choose one image as the correct image that will execute the code
set_image.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/new_build_resize_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/setting">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set Image "
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="38dp"
android:textColor="#color/abc_primary_text_material_light" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select one graphical passcode as your lock screen."
android:id="#+id/textView2"
android:textSize="22dp"
android:textColor="#1547bb"
android:layout_below="#+id/textView"
android:layout_alignParentLeft="true" />
<ImageButton
android:layout_width="135dp"
android:layout_height="140dp"
android:src="#drawable/a"
android:id="#+id/imageButton1"
android:layout_above="#+id/imageView2"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView2" />
<ImageButton
android:layout_width="126dp"
android:layout_height="126dp"
android:src="#drawable/b"
android:id="#+id/imageView2"
android:layout_above="#+id/imageView3"
android:layout_alignParentLeft="true" />
<ImageButton
android:layout_width="126dp"
android:layout_height="126dp"
android:src="#drawable/c"
android:id="#+id/imageView3"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="46dp" />
</RelativeLayout>

Any Skin Selector Android library

Are there any android library that do:
Shows drawables in either a grid or scroll view.
Allows user to select one of the images and shows his selection.
Allows me to get the selected drawable and show it to the user.
Please see the screenshots to see what I'm trying to achieve.
I have done something like you are thinking about. I will show you that if is useful to you (I think will be, but you must adapt this):
Context: I have created a simple game based in Space Invaders. My game has a main menu (main activity) where the player can press 'PLAY' or scan elect some 'OPTIONS', though a popup.
App main menu image
1 screen: Main menu.
2 screen: Popup appears when I press 'OPTIONS' button. This popup let me choose graphic options (change game background, ally spaceship model and enemy spaship model).
MainActivity.java
optionBoton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
soundMenu.start();
LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View viewPopup = inflater.inflate(R.layout.popup_activity, null);
popup = new PopupWindow(
viewPopup,
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT
);
popup.showAtLocation(layoutPrincipal, Gravity.BOTTOM, 0, 0);
ImageButton closePop = (ImageButton) vistaPopup.findViewById(R.id.volver_boton);
closePop.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
soundMenu.start();
popup.dismiss();
optionBoton.setVisibility(View.VISIBLE);
}
});
optionBoton.setVisibility(View.INVISIBLE);
}
});
This code will be inside onCreate method.
Now, you need to design your own XML popup (if you decide to create a popup). Showing a popup is easy, clean and dynamic way to change the graphic options.
popup_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#839ceaac"
android:orientation="vertical">
<ImageButton
android:id="#+id/volver_boton"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_marginRight="2dp"
android:layout_marginTop="3dp"
android:background="#android:color/transparent"
android:scaleType="centerCrop"
android:src="#drawable/wcerrar" />
<TextView
android:id="#+id/options_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="6dp"
android:layout_marginTop="5dp"
android:text="Opciones gráficas"
android:textSize="20dp"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="#id/options_title"
android:background="#9dc8a6" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/options_title"
android:layout_marginBottom="8dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="#+id/back_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:text="Fondo"
android:textSize="15sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/back_1"
android:layout_width="40dp"
android:layout_height="60dp"
android:layout_below="#id/back_title"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:adjustViewBounds="true"
android:onClick="uploadBack"
android:scaleType="centerCrop"
android:src="#drawable/fondo" />
<ImageView
android:id="#+id/back_2"
android:layout_width="40dp"
android:layout_height="60dp"
android:layout_below="#id/back_1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:adjustViewBounds="true"
android:onClick="uploadBack"
android:scaleType="centerCrop"
android:src="#drawable/fondo1" />
<ImageView
android:id="#+id/back_3"
android:layout_width="40dp"
android:layout_height="60dp"
android:layout_below="#id/back_2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:adjustViewBounds="true"
android:onClick="uploadBack"
android:scaleType="centerCrop"
android:src="#drawable/fondo3" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="#+id/spaceship_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:text="Spaceship"
android:textSize="15sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/spaceship_1"
android:layout_width="40dp"
android:layout_height="60dp"
android:layout_below="#id/spaceship_title"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:adjustViewBounds="true"
android:onClick="uploadSpaceship"
android:src="#drawable/diseno11" />
<ImageView
android:id="#+id/spaceship_2"
android:layout_width="40dp"
android:layout_height="60dp"
android:layout_below="#id/spaceship_1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:adjustViewBounds="true"
android:onClick="uploadSpaceship"
android:src="#drawable/diseno21" />
<ImageView
android:id="#+id/spaceship_3"
android:layout_width="40dp"
android:layout_height="60dp"
android:layout_below="#id/spaceship_2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:adjustViewBounds="true"
android:onClick="uploadSpaceship"
android:src="#drawable/diseno31" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="#+id/enemy_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:text="Enemies"
android:textSize="15sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/enemy_1"
android:layout_width="40dp"
android:layout_height="60dp"
android:layout_below="#id/enemy_title"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:adjustViewBounds="true"
android:onClick="uploadEnemy"
android:rotation="180"
android:src="#drawable/enemigodiseno11" />
<ImageView
android:id="#+id/enemy_2"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_below="#id/enemy_1"
android:layout_marginBottom="3dp"
android:layout_centerHorizontal="true"
android:src="#drawable/enemigodiseno21"
android:onClick="uploadEnemy"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Anyway, if you choose to don't use a popup, I will show you how you can send some data to another activity in Android development:
When you press on a graphic option, look at the call "android:onclick". This allows to call a java method to capture the option selected.
Look a simple example of this:
Method example
public void uploadBack(View view) {
switch (view.getId()) {
case R.id.back_1:
result[0] = "back";
break;
case R.id.back_2:
result[0] = "back1";
break;
case R.id.back_3:
result[0] = "back3";
break;
}
}
As you can see, I have an array of Strings with 3 positions. When I click an ImageView, I call the method wich changes the result[i] value. When I press 'PLAY' and I call the game activity, I use putExtra method to send these options and change the game settings.
I hope this serve as a help for your problem.
Have a nice day!

Why doesn't Eclipse detect new onClick method I've added in my layout file

Here is my full layout file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:onClick="showButtons"
android:text="#string/buttons_label" />
</RelativeLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout1"
android:layout_centerHorizontal="true"
android:onClick="showSpinners"
android:text="#string/spinners_label" />
</RelativeLayout>
And here is where I call showSpinners:
private void showSpinners(View clickedButton){
goToActivity(SpinnerActivity.class);
}
Eclipse underlines in yellow showSpinners by saying it's never used locally, my guess is it is not detecting my onClick attribute in the layout file.
I'm wondering why it just wont work and what I should do to make it work...
Change the your method to :
public void showSpinners(View clickedButton) {
// do the work
}
The method needs to be visible outside the class (source).

Is there any Data Grid control available for android?

I am looking for including a pre-built data grid control in a data-driven to display data in a tabular form just like we do in desktop or web applications. I am aware that there are alternate ways available just like we have it here:
How to create a DataGrid display in android?
Any other good alternate?
I wrote one. It supports image buttons, text view and edit text. Clicking on a column header will sort the data. Also a column can be set as clickable. If interested I can send you my code.
Here is a sample layout file using the code.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:tg="http://schemas.android.com/apk/res/com.ra.music"
xmlns:pc="http://schemas.android.com/apk/res/com.ra.music"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MusicActivity" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/music_header" />
<com.ra.playercontrol.PlayerControl
android:id="#+id/player_control"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
pc:editSong="true" />
<ScrollView
android:id="#+id/table_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:scrollbars="vertical|horizontal" >
<com.ra.tablegrid.TableGrid
android:id="#+id/music_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:stretchColumns="*" >
<com.ra.tablegrid.TableTextView
android:id="#+id/song_id"
tg:fieldName="song_id"
tg:keyField="true"
tg:visible="false" />
<com.ra.tablegrid.TableImageButton
android:id="#+id/play_song"
android:src="#drawable/play_button_up"
tg:displayOrder="02"
tg:fieldName="play_song"
tg:down_src_table="#drawable/play_button_down" />
<com.ra.tablegrid.TableImageButton
android:id="#+id/edit_song"
android:src="#drawable/edit_button_up"
tg:displayOrder="03"
tg:fieldName="edit_song"
tg:down_src_table="#drawable/edit_button_down" />
<com.ra.tablegrid.TableImageButton
android:id="#+id/delete_song"
android:src="#drawable/delete_button_up"
tg:displayOrder="04"
tg:fieldName="delete_song"
tg:down_src_table="#drawable/delete_button_down" />
<com.ra.tablegrid.TableTextView
android:id="#+id/song_name"
android:textSize="16sp"
tg:clickable="true"
tg:displayOrder="07"
tg:fieldName="song_name"
tg:sortable="true"
tg:fieldPercent="0.26"
tg:title="#string/song_name" />
<com.ra.tablegrid.TableTextView
android:id="#+id/artist"
android:textSize="13sp"
tg:displayOrder="10"
tg:fieldName="artist"
tg:secondarySorts="song_name"
tg:sortable="true"
tg:fieldPercent="0.13"
tg:title="#string/artist" />
<com.ra.tablegrid.TableTextView
android:id="#+id/cd_name"
android:textSize="13sp"
tg:displayOrder="15"
tg:fieldName="cd_name"
tg:secondarySorts="song_name"
tg:sortable="true"
tg:fieldPercent="0.14"
tg:title="#string/cd_name" />
<com.ra.tablegrid.TableTextView
android:id="#+id/category"
android:textSize="13sp"
tg:displayOrder="20"
tg:fieldName="category"
tg:secondarySorts="qualifier1,qualifier2,song_name"
tg:sortable="true"
tg:fieldPercent="0.08"
tg:title="#string/category" />
<com.ra.tablegrid.TableTextView
android:id="#+id/qualifier1"
android:textSize="13sp"
tg:displayOrder="25"
tg:fieldName="qualifier1"
tg:secondarySorts="qualifier2,song_name"
tg:sortable="true"
tg:fieldPercent="0.10"
tg:title="#string/qualifier1" />
<com.ra.tablegrid.TableTextView
android:id="#+id/qualifier2"
android:textSize="13sp"
tg:displayOrder="30"
tg:fieldName="qualifier2"
tg:secondarySorts="song_name"
tg:sortable="true"
tg:fieldPercent="0.14"
tg:title="#string/qualifier2" />
<com.ra.tablegrid.TableTextView
android:id="#+id/length"
android:textSize="13sp"
tg:displayOrder="35"
tg:fieldName="length"
tg:sortable="true"
tg:fieldPercent="0.08"
tg:title="#string/length" />
</com.ra.tablegrid.TableGrid>
</ScrollView>
And here is a code snipet for implementing the table.
mTableGrid.setInitialSort("song_name", true);
mTableGrid.setOnTableClickListener(new ITableClickListener() {
#Override
public void onTableClick(String columnName, String keyValue) {
MusicActivity.this.onTableClick(columnName, keyValue);
}
});
private void populateTable(ArrayList<DisplaySong> displaySongs) {
mTableGrid.clearData();
for (DisplaySong song : displaySongs) {
mTableGrid.addDataRow(createTableDataRow(song));
}
mTableGrid.buildTable();
}

Categories

Resources