<?xml version="1.0" encoding="utf-8"? > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <RelativeLayout android:layout_width="match_parent" android:layout_height="426dp" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:text="Welcome to main activity " android:textColor="#ffffff" android:textSize="15sp" /> <Button android:id="@+id/btn_intent_explicit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/btnLifeCycle" android:layout_below="@+id/btnLifeCycle" android:text="Intent(Explicit)" android:textSize="8sp" /> </RelativeLayout> </LinearLayout> </LinearLayout>
package com.uk.modak; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class ProjectonOverallClassMainActivity extends Activity { public Button btn_intent_explicit; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btn_intent_explicit = (Button) findViewById(R.id.btn_intent_explicit); btn_intent_explicit.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent z = new Intent(ProjectonOverallClassMainActivity.this,ExplicitIntentHomeActivity.class); startActivity(z); } }); } public void onStart(){ super.onStart(); } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:text="Welcome explicit home layout" /> <Button android:id="@+id/btnTrue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/textView1" android:layout_marginLeft="44dp" android:layout_marginTop="145dp" android:text="True" /> <Button android:id="@+id/btnFalse" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/btnTrue" android:layout_alignBottom="@+id/btnTrue" android:layout_alignParentRight="true" android:layout_marginRight="49dp" android:text="False" /> <EditText android:id="@+id/editTextShowTrueFalse" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginTop="33dp" android:ems="10" android:inputType="textPersonName" ></EditText> <Button android:id="@+id/btnGoInnerPage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/btnTrue" android:layout_centerHorizontal="true" android:layout_marginTop="74dp" android:text="Show result on inner page" /> </RelativeLayout> </LinearLayout>
package com.uk.modak; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class ExplicitIntentHomeActivity extends Activity { private EditText editTextShowTrueFalse; private Button btnTrue; private Button btnFalse; public Button btnGoInnerPage; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.explicitintenthome); editTextShowTrueFalse = (EditText) findViewById(R.id.editTextShowTrueFalse); btnTrue = (Button) findViewById(R.id.btnTrue); btnFalse = (Button) findViewById(R.id.btnFalse); btnGoInnerPage = (Button) findViewById(R.id.btnGoInnerPage); btnTrue.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { editTextShowTrueFalse.setText("True"); //Toast.makeText(GeoQuizActivity.this,R.string.trueToast,Toast.LENGTH_LONG).show(); } }); btnFalse.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { editTextShowTrueFalse.setText("False"); //Toast.makeText(GeoQuizActivity.this,R.string.false_Toast,Toast.LENGTH_LONG).show(); } }); btnGoInnerPage.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent m = new Intent(ExplicitIntentHomeActivity.this,ExplicitIntentInnerActivity.class); m.putExtra(ExplicitIntentInnerActivity.GET_RESULT, editTextShowTrueFalse.getText().toString()); startActivityForResult(m,0); } }); } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:text="Welcome to explicit inner layout" /> <Button android:id="@+id/btnPress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_centerVertical="true" android:layout_marginLeft="42dp" android:text="Press" /> </RelativeLayout> </LinearLayout>
package com.uk.modak; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class ExplicitIntentInnerActivity extends Activity { public static final String GET_RESULT=""; private Button btnPress; private String answer =""; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.explicitintentinner); btnPress = (Button) findViewById(R.id.btnPress); System.out.println(GET_RESULT); System.out.println("next"); answer = getIntent().getStringExtra(GET_RESULT); System.out.println(answer); btnPress.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(ExplicitIntentInnerActivity.this, answer,Toast.LENGTH_LONG).show(); /*if(answer=="True") { edittextShowInner.setText("True"); } else { edittextShowInner.setText("False"); }*/ } }); } }
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".ProjectonOverallClassMainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".ExplicitIntentInnerActivity" android:label="@string/app_name" > </activity> <receiver android:name=".ConnectionReceive"> <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver> </application>
Total : 27273
Today :9
Today Visit Country :