LİNEAR LAYOUT2

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:text="Click"/>


</LinearLayout> İLK LAYOUT BURDA LİNEAR LAYOUT OLUŞTURDUK.VERTİCAL ŞEKİLDE BELİRLEDİK. DAHA SONRA İSE BİR ADET BUTON OLUŞTURUP İSİM BELİRLEDİK.
package com.example.enespecenek.gelecegiyazanlar;

import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;


import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button a=(Button) findViewById(R.id.button1);
a.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
startActivity(new Intent(MainActivity.this,LineerLayoutGecis.class));

}
});

}
}
//BURDA İSE ACTİVİY SINIFINDA BUTONU TANIMLAYIP DAHA SONRA SETONCLICKLISTENER İLE DOKUNMA DURUMUNDA NE OLCAGINI BELİRTTİK. BURDA ŞU KOMUT SATIRI İLE startActivity(new Intent(MainActivity.this,LineerLayoutGecis.class));
SAYFALAR ARASI GEÇİŞ YAPMAKATAYIZ.NEW INTENT İLE INTENT OLUŞTURDUK.BULUNDUGU SAYFADAN BAŞKA BİR SAYFAYA GECMESİNİ SAGLADIK.

LİNEARLAYOUT2DE İSE 

ŞU ŞEKİLDE OLMAKTADIR.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:text="Okul"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button3"
android:text="Dersane"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button4"
android:text="Hobi"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button5"
android:text="Sınav"/>

</LinearLayout> BU ŞEKİLDE LAYOUT BELİRLEDİK BU LAYOUTTA 4 ADET BUTON TANIMLADIK İD DEGERİ VERDİK
DAHA SONRA İSE BUNLARA YENİ OLŞTURDUGUMUZ ACTİVİTYDE TANIMLADIK.
package com.example.enespecenek.gelecegiyazanlar;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class LineerLayoutGecis extends Activity {
public static final int a=1;
public static final int b=2;
public static final int c=3;
public static final int d=4;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lineerlayoutgecis);
Button button=(Button) findViewById(R.id.button2);
Button button1=(Button) findViewById(R.id.button3);
Button button2=(Button) findViewById(R.id.button4);
Button button3=(Button) findViewById(R.id.button5);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Show(d);
}
});
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Show(c);
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Show(b);
}
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Show(a);
}
});
}
private void Show(int deger)
{
Intent ıntent=new Intent(LineerLayoutGecis.this,LineerLayoutGecis2.class);
ıntent.putExtra("Deger",deger);
startActivity(ıntent);
}
} BURDA İSE KENDİMİZ FONKSİYON OLUŞTURDUK HER TIKLAMAYA AYRI BİR DEGER VERDİK BU DEGERLERE GÖRE INTENT DEGERİNE PUTEXTRA İLE BU DEGERİ ATTIK BU DEGER SAYESİNDE RAHATLIKLA INTENT İLE SAYFALAR ARASI GECİŞ YAPABİLMEKTEYİZ. ŞU FONKSİYON İSE ŞU ŞEKILDE OLMAKTADIR. INTENT A=NEW INTENT(GECİS.THİS,GECİS2.CLASS);-->BU ACTİVYDEN DİGER ACTİVİTY GECİŞ YAPILACAK. INTENT.PUTEXTRA("DEGER",DEGER); STARTACTİVİTY İLE GEÇİŞ BAŞLATILMAKTADIR. DİGER ACTİVTY SAYFAMIZ İSE ŞU ŞEKİLDEDİR.
package com.example.enespecenek.gelecegiyazanlar;

import android.app.Activity;
import android.os.Bundle;

/**
* Created by EnesPecenek on 31.12.2015.
*/
public class LineerLayoutGecis2 extends Activity{
protected void onCreate(Bundle savedIntanceState)
{
super.onCreate(savedIntanceState);
int deger=getIntent().getIntExtra("Example",0);
switch (deger) {
case LineerLayoutGecis.a:
setContentView(R.layout.lineerlayoutgecis);
break;
case LineerLayoutGecis.b:
setContentView(R.layout.support_simple_spinner_dropdown_item);
break;
case LineerLayoutGecis.c:
setContentView(R.layout.activity_main);
break;
case LineerLayoutGecis.d:
setContentView(R.layout.lineerlayoutgecis);
break;

default:
break;
}
}
} BURDA İSE INT A=GETINTENT().GETINTEXTRA("DEGER",0); DEGERİ ALIP ONA GORE SAYFA BAŞLATILMAKTADIR. BUNLARIN HEPSİNİDE ACTİVİTYDE TANIMLAMAK GEREKMEKTEDİR.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.enespecenek.gelecegiyazanlar">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LineerLayoutGecis">
<intent-filter>
<action android:name="android.intent.action.ana"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".LineerLayoutGecis2">
<intent-filter>
<action android:name="android.intent.action.baba"/>

<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>

</manifest>




 
Sitemizin tüm hakları saklıdır.
Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol