Created
December 16, 2019 13:36
-
-
Save orhanerday/9bf0ca571642da8285e62b5c3123a4d4 to your computer and use it in GitHub Desktop.
XamarinDosya Kurt Holland
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Android.App; | |
using Android.Content; | |
using Android.OS; | |
using Android.Runtime; | |
using Android.Views; | |
using Android.Widget; | |
namespace listview | |
{ | |
[Activity(Label = "Activity1")] | |
public class Activity1 : Activity | |
{ | |
TextView textView1; | |
protected override void OnCreate(Bundle savedInstanceState) | |
{ | |
base.OnCreate(savedInstanceState); | |
// Create your application here | |
SetContentView(Resource.Layout.layout1); | |
textView1 = FindViewById<TextView>(Resource.Id.textView1); | |
textView1.Text = ""; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
android:minWidth="25px" | |
android:minHeight="25px"> | |
<ListView | |
android:minWidth="25px" | |
android:minHeight="25px" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:id="@+id/mainListview" /> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
android:gravity="center"> | |
<TextView | |
android:text="Text" | |
android:textSize="@dimen/abc_text_size_display_3_material" | |
android:gravity="center" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:minWidth="25px" | |
android:minHeight="25px" | |
android:id="@+id/textView1" /> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Android.App; | |
using Android.OS; | |
using Android.Support.V7.App; | |
using Android.Runtime; | |
using Android.Widget; | |
namespace listview | |
{ | |
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)] | |
public class MainActivity : AppCompatActivity | |
{ | |
string[] data; | |
protected override void OnCreate(Bundle savedInstanceState) | |
{ | |
base.OnCreate(savedInstanceState); | |
Xamarin.Essentials.Platform.Init(this, savedInstanceState); | |
// Set our view from the "main" layout resource | |
SetContentView(Resource.Layout.activity_main); | |
data = new string[] { "Volkan", | |
"Isla", | |
"Skrtel", | |
"Neto", | |
"Hasan Ali", | |
"Souza", | |
"Ozan", | |
"Giuliano", | |
"Alper", | |
"Valbuena", | |
"Janssen"}; | |
//Yeni adaptör oluşturuluyor. | |
//Android.Resource.Layout.SimpleListItem1 : Bu parametre listviewımızın tipini belirtiyor. | |
ArrayAdapter arrayAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, data); | |
//Main.axml dosyasında ki Listview objemizi çekiyoruz. | |
ListView mainListView = FindViewById<ListView>(Resource.Id.mainListview); | |
//Adaptör veriliyor. | |
mainListView.Adapter = arrayAdapter; | |
//Bir veriye tıklandığında yapılacka işlem. | |
mainListView.ItemClick += MainListView_ItemClick; | |
} | |
private void MainListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e) | |
{ | |
//Tıklanan satır yakalanır, ekrana basılır. | |
StartActivity(typeof(Activity1)); | |
// Toast.MakeText(this, data[e.Position].ToString(), ToastLength.Long).Show(); | |
} | |
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults) | |
{ | |
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults); | |
base.OnRequestPermissionsResult(requestCode, permissions, grantResults); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment