tak wygląda cały kod:
package com.example.clientform;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class UserForm extends Activity
{
public boolean Agree = false;
public boolean Send = false;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.userform);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
TextView tv = (TextView) findViewById(R.id.tv_title);
TextView tv1 = (TextView) findViewById(R.id.tv_Surname);
TextView tv2 = (TextView) findViewById(R.id.tv_Email);
TextView tv3 = (TextView) findViewById(R.id.tv_Name);
TextView tv4 = (TextView) findViewById(R.id.tv_checkin);
EditText et = (EditText) findViewById(R.id.et_Surname);
EditText et1 = (EditText) findViewById(R.id.et_Name);
et1.setCursorVisible(true);
EditText et2 = (EditText) findViewById(R.id.et_Email);
et.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
et1.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
et2.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
TextView tv5 = (TextView) findViewById(R.id.tv_hear);
TextView tv6 = (TextView) findViewById(R.id.tv_accept);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Olifant-Normal.ttf");
Typeface tf1 = Typeface.createFromAsset(getAssets(), "fonts/AauxNext-Rg.ttf");
Typeface tf2 = Typeface.createFromAsset(getAssets(), "fonts/AauxNext-Bd.ttf");
tv.setTypeface(tf2);
tv1.setTypeface(tf2);
tv2.setTypeface(tf2);
tv3.setTypeface(tf2);
tv4.setTypeface(tf1);
tv5.setTypeface(tf);
tv6.setTypeface(tf1);
ArrayList<String> options = new ArrayList<String>();
options.add("Mr");
options.add("Mrs");
options.add("Miss");
Spinner sp = (Spinner) findViewById(R.id.sp_title);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, options);
sp.setAdapter(adapter);
}
@Override
public void onBackPressed()
{
setResult(11);
finish();
}
public void radioOnClick(View v)
{
boolean ch = ((RadioButton) v).isChecked();
switch(v.getId())
{
case R.id.radioButton1:
if(ch)
{
Send = true;
RadioButton rb = (RadioButton) findViewById(R.id.radioButton2);
rb.setChecked(false);
}
break;
case R.id.radioButton2:
if(ch)
{
Send = false;
RadioButton rb = (RadioButton) findViewById(R.id.radioButton1);
rb.setChecked(false);
}
break;
}
}
public void conditionsli(View v)
{
CheckBox cb = (CheckBox) findViewById(R.id.cbterms);
if(cb.isChecked())
{
Agree=true;
}
else
{
Agree=false;
cb.setChecked(false);
}
}
public void onClick(View v)
{
if(ValidateFields())
{
Intent data = new Intent();
String title;
Spinner spi = (Spinner) findViewById(R.id.sp_title);
title = spi.getSelectedItem().toString();
//EditText title = (EditText) findViewById(R.id.et_Title);
EditText name = (EditText) findViewById(R.id.et_Name);
EditText surname = (EditText) findViewById(R.id.et_Surname);
EditText email= (EditText) findViewById(R.id.et_Email);
data.putExtra("email", email.getText().toString());
data.putExtra("name", name.getText().toString());
data.putExtra("title", title);
data.putExtra("surname", surname.getText().toString());
data.putExtra("sendInfo", Send);
setResult(RESULT_OK, data);
finish();
}
}
public boolean ValidateFields()
{
EditText edN = (EditText) this.findViewById(R.id.et_Name);
EditText edEma = (EditText) this.findViewById(R.id.et_Email);
CheckBox cb = (CheckBox) this.findViewById(R.id.checkbox);
EditText edS = (EditText) this.findViewById(R.id.et_Surname);
CheckBox cbterms = (CheckBox) this.findViewById(R.id.cbterms);
if(!Agree)
{
cbterms.setError("You must agree!");
return false;
}
if(edN.getText().toString().length() == 0)
{
edN.setError("Fill this in!");
return false;
}
if(edS.getText().toString().length() == 0)
{
edS.setError("Fill this in!");
return false;
}
if(edEma.getText().toString().length() == 0)
{
edEma.setError("Fill this in!");
return false;
}
return true;
}
}