Android application Error passing data - java

I keep getting an error that shows:
(04-04 23:26:29.557: E/dalvikvm(716): Unable to open stack trace file '/data/anr/traces.txt': Permission denied).
Please help. I'm trying to pass Data for an android app.
public class Data extends Activity implements OnClickListener{
Button start, startFor;
EditText sendET;
TextView gotAnswer;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.get);
initialize();
}
private void initialize(){
start = (Button) findViewById(R.id.bSA);
startFor = (Button) findViewById(R.id.bSAFR);
sendET = (EditText) findViewById(R.id.etSend);
gotAnswer = (TextView) findViewById(R.id.tvGot);
start.setOnClickListener(this);
startFor.setOnClickListener(this);
}
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId()){
case R.id.bSA:
String bread = sendET.getText().toString();
Bundle basket = new Bundle();
basket.putString("key", bread);
Intent a = new Intent(Data.this,OpenedClass.class);
a.putExtras(basket);
startActivity(a);
break;
case R.id.bSAFR:
Intent i = new Intent(Data.this,OpenedClass.class);
startActivityForResult(i,0);
break;
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
}
}
package com.Christian.Amaro;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
public class OpenedClass extends Activity implements OnClickListener,
OnCheckedChangeListener {
TextView question, test;
Button returnData;
RadioGroup selectionList;
String gotBread,setData;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.send);
inilialize();
Bundle gotBasket = getIntent().getExtras();
gotBread = gotBasket.getString("key");
question.setText(gotBread);
}
private void inilialize() {
// TODO Auto-generated method stub
question = (TextView) findViewById(R.id.tvQuestion);
test = (TextView) findViewById(R.id.tvText);
returnData = (Button) findViewById(R.id.bReturn);
returnData.setOnClickListener(this);
selectionList = (RadioGroup) findViewById(R.id.rgAnswers);
selectionList.setOnCheckedChangeListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
#Override
public void onCheckedChanged(RadioGroup arg0, int arg1) {
// TODO Auto-generated method stub
switch (arg1) {
case R.id.rCrazy:
setData = "Probably right!";
break;
case R.id.rSexy:
setData = "Definitely Probably right!";
break;
case R.id.rBoth:
setData = "Spot On!";
break;
}
test.setText(setData);
}
}

adb shell
root#android: # cd /data/anr
root#android:/data/anr # ls -l traces.txt
-rw-rw-rw- system system 76808 2013-04-05 13:03 traces.txt
root#android:/data/anr #
-rw-rw-rw is what you should see (it means permissions to read and write)
If you see something different, do
root#android:/data/anr # chmod 666 traces.txt
PS Your device must be rooted, but otherwise you would be unable to get this problem :)

Related

How do i scan multiple QR codes and get the addition?

I have n QR codes containing price in integers. I want to scan each qr code and add its price to the total amount. Here is MainActivity.java
eg. If i scan a qr code containing price 40, 40 gets displayed in TextView2. how do i add n qr codes and update the total each time i scan a qrcode?
package com.mycompany.smartshoppingcart;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
private static final int ACTIVITY_RESULT_QR_DRDROID = 0;
TextView report;
Button scan;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
report = (TextView) findViewById(R.id.textView2);
scan = (Button) findViewById(R.id.button1);
scan.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i = new Intent("la.droid.qr.scan");
try {
startActivityForResult(i, ACTIVITY_RESULT_QR_DRDROID);
}
catch (ActivityNotFoundException activity) {
MainActivity.qrDroidRequired(MainActivity.this);
}
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if( ACTIVITY_RESULT_QR_DRDROID == requestCode
&& data != null && data.getExtras() != null ) {
String result = data.getExtras().getString("la.droid.qr.result");
report.setText(result);
report.setVisibility(View.VISIBLE);
}
}
/*
*
* If we don't have QRDroid Application in our Device,
* It will call below method (qrDroidRequired)
*
*/
protected static void qrDroidRequired(final MainActivity activity) {
// TODO Auto-generated method stub
AlertDialog.Builder AlertBox = new AlertDialog.Builder(activity);
AlertBox.setMessage("QRDroid Missing");
AlertBox.setPositiveButton("Direct Download", new OnClickListener() {
#Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
activity.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://droid.la/apk/qr/")));
}
});
AlertBox.setNeutralButton("From Market", new OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
activity.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://market.android.com/details?id=la.droid.qr")));
}
});
AlertBox.setNegativeButton("Cancel", new OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
});
AlertBox.create().show();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
}
You should just store this value in a global variable for the class.
at top of class add int totalCost = 0; (below Button scan; line)
Then in onActivityResult, once you get the result back from the qrcode you should cast this variable to an integer
via int cost = Integer.parseInt(result);
Once you have the integer value of the cost just add it to the total cost
totalCost += cost;
Then update the text label
report.setText("" + totalCost);

“Cannot make a static reference to a non-static method” in Android. Simply case [duplicate]

This question already has answers here:
Cannot make a static reference to the non-static method
(8 answers)
Closed 8 years ago.
I am trying to call a method after clicking on a Button but I'm getting this error:
"Cannot make a static reference to a non-static method”
here is the code, the only problematic thing in the code is when I try to call reakcja(); in button Intencja. Can you please help me?
package com.example.buttonwork;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RatingBar;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
public class MainActivity extends ActionBarActivity {
public void reakcja(){
Intent i = new Intent(this, Intencja.class);
startActivity(i);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i("click", "On create!");
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
Log.i("click","Teraz chyba pierwszy zapis instancji");
}
}
#Override
public void onStop(){
Log.i("click","onStop");
super.onStop();
}
#Override
public void onPause(){
Log.i("click","onPause");
super.onPause();
}
#Override
public void onResume(){
Log.i("click","onResume");
super.onResume();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
Log.i("click","Pierwsze tworzenie menu?");
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
//Toast.makeText(item.getContext(), "elo", Toast.LENGTH_SHORT).show();
Log.i("click", "menu");
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
Button but1;
Button Intencja;
TextView tv1;
EditText et1;
Button raf,kas;
ToggleButton off;
SeekBar sk1;
int kto;
CheckBox cb1,cb2;
RatingBar rb1;
public PlaceholderFragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
Log.i("click","Tutaj wszystko sie dzieje");
rb1 = (RatingBar) (rootView.findViewById(R.id.rb1));
/*rb1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(v.getContext(), String.valueOf(rb1.getProgress()), Toast.LENGTH_SHORT).show();
}
});*/
rb1.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
#Override
public void onRatingChanged(RatingBar ratingBar, float rating,
boolean fromUser) {
// TODO Auto-generated method stub
Toast.makeText(ratingBar.getContext(), String.valueOf(rating), Toast.LENGTH_SHORT).show();
}
});
Intencja = (Button) (rootView.findViewById(R.id.Intencja));
Intencja.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
reakcja();
}
});
cb1 = (CheckBox) (rootView.findViewById(R.id.cb1));
cb2 = (CheckBox) (rootView.findViewById(R.id.cb2));
off = (ToggleButton) (rootView.findViewById(R.id.toggleButton1));
off.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(v.getContext(), off.getText(), Toast.LENGTH_SHORT).show();
}
});
sk1 = (SeekBar) (rootView.findViewById(R.id.seekBar1));
sk1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
#Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
//Toast.makeText(seekBar.getContext(), String.valueOf(progress), Toast.LENGTH_SHORT).show();
tv1.setText(String.valueOf(progress));
return;
}
});
/*sk1.setOnSeekBarChangeListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(v.getContext(), sk1.getProgress(), Toast.LENGTH_SHORT).show();
}
});*/
tv1 = (TextView) (rootView.findViewById(R.id.tv1));
et1 = (EditText) (rootView.findViewById(R.id.et1));
raf = (Button) (rootView.findViewById(R.id.button1));
raf.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(v.getContext(), "Ralfo jest miszczem", Toast.LENGTH_SHORT).show();
kto = 1;
sk1.setProgress(50);
}
});
kas = (Button) (rootView.findViewById(R.id.button2));
kas.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(v.getContext(), "Nie, to Ralfo jest miszczem", Toast.LENGTH_SHORT).show();
kto =2;
sk1.setProgress(50);
}
});
but1 = (Button) (rootView.findViewById(R.id.b1));
but1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
tv1.setText(et1.getText().toString());
Toast.makeText(v.getContext(), String.valueOf(cb1.isChecked() && cb2.isChecked()), Toast.LENGTH_SHORT).show();
// wyświetla Toasta true albo false sprawdzając CheckBoxy i robiąc na nich koniunkcję
}
});
return rootView;
}
}
}
PlaceholderFragment is a static class, so you cannot call non-static method reakcja() from it. Make reakcja() static or PlaceholderFragment non-static.

Shared Preferences not found

Im trying to load SharedPreferences but the shared preferences never gets found, and im trying to update it from another class but that doesn't work as well. Im using a lst adapter for a list vieew as well. Any idea's for the following code? Im getting the back up hello string for the list view.
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class WorldMenu extends ListActivity{
SharedPreferences prefs = null;
String splitter;
String[] worldList;
Context context;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
context = getBaseContext();
prefs = context.getSharedPreferences("worldString", 1);
splitter = "Create World," + prefs.getString("worldString", "hello");
worldList = splitter.split(",");
setListAdapter(new ArrayAdapter<String>(WorldMenu.this,
android.R.layout.simple_list_item_1, worldList));
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
if(position == 0){
Intent openWorldNamer = new Intent("this works no need to check");
startActivity(openWorldNamer);
}
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
Edit Updater Class:
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class WorldCreator extends Activity{
EditText worldNameEditor;
Button saver;
SharedPreferences prefs;
OnSharedPreferenceChangeListener listener;
String updater2;
Editor editor;
String updater;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_worldcreator);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
worldNameEditor = (EditText) findViewById(R.id.hello);
saver = (Button) findViewById(R.id.button1);
updater2 = worldNameEditor.getText().toString() + ",";
saver.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
updater = updater2;
editor = prefs.edit();
editor.putString("worldString", updater);
editor.commit();
Intent openListWorld = new
Intent("the list activity");
startActivity(openListWorld);
}});
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
}
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
}
}
Until you create preferences they don't exist, so you'll always see "hello".
Here is some code I use to set a value:
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
Editor editor = sharedPreferences.edit();
editor.putBoolean("LicenseAccepted", true);
editor.commit();
Note that this not using a named file as you are, but the concept is the same :-)

How to send Picture taken from Camera through email Android

I am writting an application for educational purposes in which user takes a picture from camera and sends it via email. I wrote almost all the code except the code whi But I don't know how to do it as I am learning android. Here is my code, What should I add in this code:
package com.umer.practice2;
import java.io.IOException;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
public class SendPhoto extends Activity implements View.OnClickListener{
TextView tv1,tv2;
EditText e1,e2;
ImageView pi;
ImageButton pb;
Button pb1,pb2;
Intent photo;
Bitmap bmp;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.sendphoto);
pb1.setOnClickListener(this);
pb2.setOnClickListener(this);
pb.setOnClickListener(this);
initializeView();
}
private void initializeView() {
// TODO Auto-generated method stub
tv1= (TextView) findViewById(R.id.pt1);
tv2= (TextView) findViewById(R.id.pt2);
e1= (EditText) findViewById(R.id.pe1);
e2= (EditText) findViewById(R.id.pe2);
pi= (ImageView) findViewById(R.id.p1);
pb= (ImageButton) findViewById(R.id.pib2);
pb1= (Button) findViewById(R.id.pbut1);
pb2= (Button) findViewById(R.id.pbut2);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.pbut1:
String email[]={e2.getText().toString()};
Intent emailIntent= new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, email);
emailIntent.setType("image/jpeg");
startActivityForResult(emailIntent, 1);
break;
case R.id.pib2:
photo= new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(photo,2);
break;
case R.id.pbut2:
try {
getApplicationContext().setWallpaper(bmp);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
pi.setImageBitmap(bmp);
}
}
In you onActivityResult method you should save the bitmap into a file on your SD-Card, next you should attach a file to the email intent.
how to save image to a file on sd-card
How to save a bitmap into phone's gallery?
how to attach file to an email intent:
Trying to attach a file from SD Card to email

Retrieve item from Spinner and put Some conditions

i have 2 arrays first for Hours and second for minutes, this is my arrays declare it in string.xml
` <string-array name="feedbacktypelist">
<item>#string/hr0</item>
<item>#string/hr1</item>
<item>#string/hr2</item>
</string-array>
<string-array name="array2">
<item>#string/min5</item>
<item>#string/min10</item>
<item>#string/min15</item>
<item>#string/min20</item>
<item>#string/min25</item>
<item>#string/min30</item>
<item>#string/min35</item>
<item>#string/min40</item>
<item>#string/min45</item>
<item>#string/min50</item>
<item>#string/min55</item>
<item>#string/min59</item>
</string-array>`
and this is my code in java
package lmp.app.pkg;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class CreateNewForm extends Activity implements OnItemSelectedListener {
Button Browse;
ImageView CasePic;
Spinner CaseDurationH, CaseDurationM;
TextView tesst;
RadioGroup GenderSelection;
EditText CaseName, CaseClothes, CaseMoreInfo, CaseAge;
Button Next;
//For Browsering Picture
private static final int SELECT_PICTURE = 1;
private String selectedImagePath;
#Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.create_new_form);
//To Call initializer Function
initializer();
//j list
// 1-For Uploading Picture
Browse.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
// in onCreate or any event where your want the user to
// select a file
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);
}
});
// 1-Name
final MyCase case1 = new MyCase();
case1.setName(CaseName.getText().toString());
// 2-Gender For Group Radio
GenderSelection.clearCheck();
GenderSelection.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.radio0:
case1.setGender("Male");
break;
case R.id.radio1:
case1.setGender("Female");
break;
default:
break;
}
}
});
//3-Age
String age = CaseAge.getText().toString();
/*int tstnum =case1.getAge();
tesst.setText(tstnum); */
//4-Duration Time
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.feedbacktypelist, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
CaseDurationH.setAdapter(adapter);
//5-Case Clothes
case1.setClothes(CaseClothes.getText().toString());
//6-Case More Information
case1.setMoreInfo(CaseMoreInfo.getText().toString());
//Move to 2nd form page
Next= (Button)findViewById(R.id.Next2);
Next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
switch (v.getId()) {
case R.id.Next2:
try
{
Intent k = new Intent(CreateNewForm.this, CreateNewForm_2.class);
startActivity(k);
}catch(Exception e){
}
break;
}
}
});
//Spinner
CaseDurationH.setOnItemSelectedListener(new OnItemSelectedListener() {
int i =CaseDurationH.getSelectedItemPosition();
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
int i = CaseDurationH.getSelectedItemPosition();
if(i==2){
CaseDurationM.setEnabled(false);
}
String str = parent.getSelectedItem().toString();
if(str.equals("hr0"))
{
}
if(str.equals("hr1"))
{
}
if(str.equals("hr2"))
{
CaseDurationM.setEnabled(false);
}
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
} });
}
// To initialize the variables
private void initializer() {
// TODO Auto-generated method stub
//This information will be filled by a user
//CasePic = (ImageView) findViewById(R.id.imageView1);
CaseName= (EditText) findViewById(R.id.caseNm);
GenderSelection= (RadioGroup) findViewById(R.id.radioGroup1);
CaseAge= (EditText) findViewById(R.id.caseaage);
tesst= (TextView) findViewById(R.id.textView8);
CaseDurationH= (Spinner) findViewById(R.id.Shr);
CaseDurationM= (Spinner) findViewById(R.id.Smin);
CaseClothes= (EditText) findViewById(R.id.caseClothes);
CaseMoreInfo= (EditText) findViewById(R.id.caseMrInfo);
CasePic = (ImageView) findViewById(R.id.casepic);
Browse = (Button) findViewById(R.id.browseCasePic);
}
//For Uploading Picture
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
}
}
}
//For Uploading Picture
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
i want:
1- retrieve the item in spinner that the user choose it, not the positon
2-if the user choose from spinner1 the item "hr02" then the spinner2 will disable
Thank you for help me, StackOverFlow members your my hero now! :")
use this
String str = parent.getSelectedItem().toString();
if(str.equals("hr2")
{
spinner2.setEnabled(false);
}
Try this:
String str = parent.getSelectedItem().toString();
if (str.equals("hr0")){
//retrieve the item as string
}
if (str.equals("hr1")){
//retrieve the item as string
}
if (str.equals("hr2")){
//retrieve the item as string
//make the 2nd spinner disable
}

Categories

Resources