BaseLayout

angularjs2

knockoutjs

framework7

jquerymobile

bootstrap

html5

css

 

 

[Activity(Label = "ActivityBaseAdapter", MainLauncher = true, Icon = "@drawable/icon")]

public class ActivityBaseAdapter : Activity { protected override void OnCreate(Bundle savedInstanceState) {

base.OnCreate(savedInstanceState);

SetContentView(Resource.Layout.layoutBaseAdapter);

ListView lv = FindViewById<ListView>(Resource.Id.listView1);

string[] list = { "title1", "title2", "title3" };

lv.Adapter = new MyBaseAdapter(this, list);

}

}

public class MyBaseAdapter : BaseAdapter<string> {

private Activity activity { get; set; }

private string[] titles;

public override string this[int position] { get { return titles[position]; } }

public MyBaseAdapter(Activity activity, string[] titles):base() {

this.activity = activity; this.titles = titles;

}

public override int Count { get { return titles.Length; } }

public override long GetItemId(int position) { return position; }

public override View GetView(int position, View convertView, ViewGroup parent) {

View view = null;

if (convertView == null) view = convertView;

else {

view=activity.LayoutInflater.Inflate(Resource.Layout.itemBaseLayout, parent);

}

TextView tv=view.FindViewById<TextView>(Resource.Id.textView1);

tv.SetTextKeepState(titles[position]); //tv.Text = titles[position];

return view;

}

}

posted @ 2016-05-15 12:12  jeffery1010  Views(656)  Comments(0Edit  收藏  举报