I actually have an activity called "Creation.java" which provides access to different tabs and that works fine.
My tabs are activities and contains different Views like EditText or Spinners. As I have a lot of datas to save (really a lot) I'd like to propose to the user to fill all the Views by switching between tabs and then, in a last Tab, to validate all the datas and write it in an xml file.
But it seems like I can't get access to the datas from, by example my first tab in order to validate it within the last tab with a validate button.
Example for a customer creation in creationclient.xml which is set in the activity CreationClient.java :
<EditText android:id="@+id/nom1"
android:layout_width="@dimen/margexlarge"
android:layout_height="wrap_content"
android:text="Nom"
/>
<EditText android:id="@+id/prenom1"
android:layou开发者_如何学Ct_width="@dimen/margexlarge"
android:layout_height="wrap_content"
android:text="Prénom"
/>
I can't get the content in validation.java, I get an error cause it can't get the String from the View :
nom1 = (EditText) findViewById(R.id.nom1);
prenom1 = (EditText) findViewById(R.id.prenom1);
validationDuDossier = (Button) findViewById(R.id.validationdudossier);
idDossier = ((nom1.getText().toString().substring(0, 2)) + (prenom1.getText().toString().substring(0,2)));
So my point is : Can I get access to the datas of a layout A in an activity B even if I've set a layout B in this activity ? Or do I have an exclusive access to the datas from the layout I set to my activity ?
You will need to link the edit text to the the last tab. By either doing for example.
info.getText().toString(lastTab);
or you could do as following
lastTab = info.getText().toString();
From there you will link the lastTab holding the information to the last Views TextView or how ever you are displaying the information.
精彩评论