Created
April 1, 2014 12:03
-
-
Save Cheesebaron/9912584 to your computer and use it in GitHub Desktop.
This file contains 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="fill_parent" | |
android:layout_height="fill_parent"> | |
<ListView | |
android:id="@+id/listView" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" /> | |
</LinearLayout> |
This file contains 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="horizontal" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content"> | |
<TextView | |
android:id="@+id/left" | |
android:layout_height="wrap_content" | |
android:layout_width="0px" | |
android:layout_weight="1" | |
android:text="left" /> | |
<TextView | |
android:id="@+id/right" | |
android:layout_height="wrap_content" | |
android:layout_width="0px" | |
android:layout_weight="1" | |
android:text="right" /> | |
</LinearLayout> |
This file contains 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
[Activity(Label = "Pseudo MultiColumn", MainLauncher = true, Icon = "@drawable/icon")] | |
public class SuperAwesomeActivity : Activity | |
{ | |
protected override void OnCreate(Bundle bundle) | |
{ | |
base.OnCreate(bundle); | |
// Set our view from the "main" layout resource | |
SetContentView(Resource.Layout.main); | |
var data = new List<SuperAwesomeModel> | |
{ | |
new SuperAwesomeModel { | |
Left = "herp", | |
Right = "derp" | |
}, | |
new SuperAwesomeModel { | |
Left = "foo", | |
Right = "bar" | |
}, | |
new SuperAwesomeModel { | |
Left = "baz", | |
Right = "qux" | |
}, | |
new SuperAwesomeModel { | |
Left = "quux", | |
Right = "corge" | |
}, | |
new SuperAwesomeModel { | |
Left = "grault", | |
Right = "garply" | |
}, | |
new SuperAwesomeModel { | |
Left = "waldo", | |
Right = "fred" | |
}, | |
}; | |
var listView = FindViewById<ListView>(Resource.Id.listView); | |
listView.Adapter = new SuperAwesomeModelAdapter(this, data); | |
} | |
} |
This file contains 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
public class SuperAwesomeModel | |
{ | |
public string Left { get; set; } | |
public string Right { get; set; } | |
} |
This file contains 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
public class SuperAwesomeModelAdapter : BaseAdapter<SuperAwesomeModel> | |
{ | |
private readonly IList<SuperAwesomeModel> _items; | |
private readonly Context _context; | |
public SuperAwesomeModelAdapter(Context context, IList<SuperAwesomeModel> items) | |
{ | |
_items = items; | |
_context = context; | |
} | |
public override long GetItemId(int position) | |
{ | |
return position; | |
} | |
public override View GetView(int position, View convertView, ViewGroup parent) | |
{ | |
var item = _items[position]; | |
var view = convertView; | |
if (view == null) | |
{ | |
var inflater = LayoutInflater.FromContext(_context); | |
view = inflater.Inflate(Resource.Layout.row, parent, false); | |
} | |
view.FindViewById<TextView>(Resource.Id.left).Text = item.Left; | |
view.FindViewById<TextView>(Resource.Id.right).Text = item.Right; | |
return view; | |
} | |
public override int Count | |
{ | |
get { return _items.Count; } | |
} | |
public override SuperAwesomeModel this[int position] | |
{ | |
get { return _items[position]; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could you please explain me how to fill database data like this.