I'm new to creating android applications and I wanted your help
Crier
no Navigation Drawer
Spinner
with 2 text boxes, a list
drop and a Submit
button where this button will have to fetch the spinner
returns and send to an e- mail address.
I'm blocked in the intent of the button to go fetch the information from spinner
and send it to the email I want. Can you help me?
xml file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="@android:color/holo_blue_light">
<ScrollView
android:id="@+id/ScrollView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="100dp">
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent">
<!--Put form controls here-->
<TextView
android:id="@+id/TextViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/feedbacktitle"
android:gravity="center"
android:textSize="10pt">
</TextView>
<EditText
android:id="@+id/EditTextName"
android:layout_height="wrap_content"
android:hint="@string/feedbackname"
android:inputType="textPersonName"
android:layout_width="fill_parent">
</EditText>
<EditText
android:id="@+id/EditTextEmail"
android:layout_height="wrap_content"
android:hint="@string/feedbackemail"
android:inputType="textEmailAddress"
android:layout_width="fill_parent">
</EditText>
<Spinner
android:id="@+id/SpinnerFeedbackType"
android:layout_height="wrap_content"
android:prompt="@string/feedbacktype"
android:layout_width="wrap_content"
android:entries="@array/feedbacktypelist">
</Spinner>
<Button
android:id="@+id/ButtonSendFeedback"
android:layout_height="wrap_content"
android:text="@string/feedbackbutton"
android:onClick="sendFeedback"
android:layout_width="wrap_content">
</Button>
</LinearLayout>
</ScrollView>
<ImageView
android:layout_width="125dp"
android:layout_height="125dp"
app:srcCompat="@mipmap/holistico"
android:id="@+id/imageView2"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp" />
</RelativeLayout>
Java file:
package com.example.fcarvalho.navigationdrawer;
import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import static android.R.attr.button;
import static com.example.fcarvalho.navigationdrawer.R.id.ScrollView01;
import static com.example.fcarvalho.navigationdrawer.R.id.start;
public class SecondFragment extends Fragment {
View myView;
private Spinner Valor;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
myView = inflater.inflate(R.layout.second_layout ,container, false);
return myView;
}
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);}
public void sendFeedback(View view) {
Button button = (Button) findViewById(R.id.ButtonSendFeedback);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//intenção do botão
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("mailto:[email protected]?subject=title&body=text");
}
});
}
final EditText nameField = (EditText) findViewById(R.id.EditTextName);
String name = nameField.getText().toString();
final EditText emailField = (EditText) findViewById(R.id.EditTextEmail);
String email = emailField.getText().toString();
final Spinner feedbackSpinner = (Spinner) findViewById(R.id.SpinnerFeedbackType);
String feedbacktype = feedbackSpinner.getSelectedItem().toString();
}
}
Thank you