本文整理汇总了C#中ListView.SetItemChecked方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.SetItemChecked方法的具体用法?C# ListView.SetItemChecked怎么用?C# ListView.SetItemChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListView
的用法示例。
在下文中一共展示了ListView.SetItemChecked方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.SelectLocation);
_locationItems = LocationFileWorker.GetLocationsFromCsvFile(Assets);
_adapter = new SelectLocationAdapter(this, _locationItems);
_myListView = FindViewById<ListView>(Resource.Id.list_view);
_myListView.Adapter = _adapter;
_inputSearch = FindViewById<EditText>(Resource.Id.inputSearch);
_inputSearch.TextChanged += InputSearchOnTextChanged;
var applyBtn = FindViewById<Button>(Resource.Id.Apply_btn);
applyBtn.Click += applyBtn_Click;
_myListView.ChoiceMode = ChoiceMode.Single;
_myListView.ItemClick += lv_ItemClick;
if (!String.IsNullOrEmpty(Settings.CityName))
{
int previouslySelectedIndex = _locationItems.FindIndex(i => i.CityName == Settings.CityName);
_myListView.SetItemChecked(previouslySelectedIndex, true);
}
else
_myListView.SetItemChecked(0, true);
}
示例2: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.SoundSelection);
_items = new List<SoundItem>();
_selectSoundListView = FindViewById<ListView>(Resource.Id.selectSound);
_selectSoundListView.ChoiceMode = ChoiceMode.Single;
var applyBtn = FindViewById<Button>(Resource.Id.Apply_btn);
applyBtn.Click += ApplyBtnOnClick;
var fields = typeof(Resource.Raw).GetFields();
int index = 0;
foreach (var fieldInfo in fields.ToList())
{
_items.Add(new SoundItem { Position = index, SoundName = fieldInfo.Name});
index++;
}
_adapter = new SelectSoundAdapter(this, _items);
_selectSoundListView.Adapter = _adapter;
_selectSoundListView.ItemClick += selectSoundListView_ItemClick;
if (!string.IsNullOrEmpty(Settings.WakeUpSound))
{
var previouslySelectedItemIndex = _items.FindIndex(i=> i.SoundName == Settings.WakeUpSound);
_selectSoundListView.SetItemChecked(previouslySelectedItemIndex, true);
}
}
示例3: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
int calcNo = Intent.GetIntExtra("CalculationType",-1);
SetContentView (Resource.Layout.PercentDrawer);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);
drawerLayout.SetBackgroundColor(Android.Graphics.Color.AntiqueWhite);
ColorDrawable colorDrawable = new ColorDrawable (Color.Black);
this.ActionBar.SetBackgroundDrawable (colorDrawable);
drawerToggle = new ActionBarDrawerToggle (this, drawerLayout, Resource.String.DrawerOpenDescription, Resource.String.DrawerCloseDescription);
drawerLayout.SetDrawerListener (drawerToggle);
drawerListView = FindViewById<ListView> (Resource.Id.drawerListView);
drawerListView.Adapter = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleListItem1, calculationTitles);
drawerListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => OnMenuItemClick(e.Position);
drawerListView.SetItemChecked (calcNo, true);
OnMenuItemClick (calcNo);
ActionBar.SetDisplayHomeAsUpEnabled (true);
}
示例4: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.CourseActivity);
//code with drawer
courseCategoryManager = new CourseCategoryManager();
courseCategoryManager.MoveFirst();
String displayCategoryTitle = courseCategoryManager.Current.CategoryTitle;
// String displayCategoryTitle = DEFAULT_CATEGORY_TITLE;
//Intent startupIntent = this.Intent;
//if (startupIntent != null)
//{
// String displayCategoryTitleExtra = startupIntent.GetStringExtra(DISPLAY_CATEGORY_TITLE_EXTRA);
// if (displayCategoryTitleExtra != null)
// displayCategoryTitle = displayCategoryTitleExtra;
//}
courseManager = new CourseManager(displayCategoryTitle);
courseManager.MoveFirst();
coursePagerAdapter = new CoursePagerAdapter(SupportFragmentManager, courseManager);
viewPager = FindViewById<ViewPager>(Resource.Id.coursePager);
viewPager.Adapter = coursePagerAdapter;
//drawer
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);
categoryDrawerListView = FindViewById<ListView>(Resource.Id.categoryDrawerListView);
//categoryDrawerListView.Adapter =
// new CourseCategoryManagerAdapter(this, Android.Resource.Layout.SimpleListItem1, courseCategoryManager);
categoryDrawerListView.Adapter =
new CourseCategoryManagerAdapter(this,Resource.Layout.CourseCategoryItem, courseCategoryManager);
//android selected as default
categoryDrawerListView.SetItemChecked(0, true);
//click event for categories
categoryDrawerListView.ItemClick += categoryDrawerListView_ItemClick;
}
示例5: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
_logging.WriteLine(Lib.Logging.MessageType.Information, "Starting application in MainActivity OnCreate method");
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
SetContentView(Resource.Layout.Main);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, Resource.String.DrawerOpenDescription, Resource.String.DrawerCloseDescription);
drawerLayout.SetDrawerListener(drawerToggle);
ActionBar.SetIcon(Android.Resource.Color.Transparent);
ActionBar.SetDisplayHomeAsUpEnabled(true);
drawerListView = FindViewById<ListView>(Resource.Id.drawerListView);
menuAdapter = new MenuAdapter (this);
drawerListView.Adapter = menuAdapter;
drawerListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => OnMenuItemClick(e.Position);
var aboutFrag = menuAdapter.MenuItems.FirstOrDefault(x => x.Manager.GetType() == typeof(AboutFragment));
var aboutPos = menuAdapter.MenuItems.IndexOf (aboutFrag);
drawerListView.SetItemChecked(aboutPos, true); // Highlight the About Fragment at startup
OnMenuItemClick(aboutPos); // Load About Fragment at startup
}
示例6: OnCreateView
/// <inheritdoc />
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ZTnTrace.Trace(MethodBase.GetCurrentMethod());
drawerListView = (ListView)inflater.Inflate(Resource.Layout.NavigationDrawer, container, false);
drawerListView.ItemClick += (sender, e) => SelectItem(e.Position);
var listItems = new[]
{
Resources.GetString(Resource.String.BattleTags),
Resources.GetString(Resource.String.Settings)
};
drawerListView.Adapter = new ArrayAdapter<string>(
Activity.ActionBar.ThemedContext,
Android.Resource.Layout.SimpleListItemActivated1,
Android.Resource.Id.Text1,
listItems);
drawerListView.SetItemChecked(currentSelectedPosition, true);
return drawerListView;
}
示例7: OnCreateView
public override global::Android.Views.View OnCreateView(LayoutInflater inflater, ViewGroup
container, Bundle savedInstanceState)
{
mDrawerListView = (ListView)inflater.Inflate(Resource.Layout.fragment_list_drawer, container, false);
mDrawerListView.ItemClick += async (sender, e) =>
SelectListItem (e.Position, true);
mDrawerListView.SetAdapter(mListsAdapter);
if (mCurrentSelectedPosition > mListsAdapter.GetCount())
{
mDrawerListView.SetItemChecked(mCurrentSelectedPosition, true);
}
return mDrawerListView;
}
示例8: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// load the main layout
SetContentView(Resource.Layout.CourseActivity);
courseCategoryManager = new CourseCategoryManager();
courseCategoryManager.MoveFirst();
String displayCategoryTitle = courseCategoryManager.Current.Title;
//String displayCategoryTitle = DEFAULT_CATEGORY_TITLE;
//Intent startupIntent = this.Intent;
//if (startupIntent != null)
//{
// String displayCategoryTitleExtra = startupIntent.GetStringExtra(DISPLAY_CATEGORY_TITLE_EXTRA);
// if (displayCategoryTitleExtra != null)
// {
// displayCategoryTitle = displayCategoryTitleExtra;
// }
//}
// create courseManager and move to start of courseList
courseManager = new CourseManager(displayCategoryTitle);
courseManager.MoveFirst();
// coursePagerAdapter is used to link together the fragments and the data
// SupportFragmentManager is a member of FragmentActivity, and allows us to manage fragments
coursePagerAdapter = new CoursePagerAdapter(SupportFragmentManager, courseManager);
// Sets the layout for each fragment
viewPager = FindViewById<ViewPager>(Resource.Id.coursePager);
viewPager.Adapter = coursePagerAdapter;
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);
categoryDrawerListView = FindViewById<ListView>(Resource.Id.categoryDrawerListView);
categoryDrawerListView.Adapter = new CourseCategoryManagerAdapter(this, Resource.Layout.CourseCategoryItem, courseCategoryManager);
categoryDrawerListView.SetItemChecked(0, true);
categoryDrawerListView.ItemClick += categoryDrawerListView_ItemClick;
}
示例9: OnCreate
protected override void OnCreate(Bundle bundle)
{
SetTheme (Resource.Style.Theme_Sherlock);
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
list = FindViewById<ListView> (Resource.Id.list);
drawer = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
adapter = new CustomAdapter (this, list_text);
list.Adapter = adapter;
fragA = new FragmentA ();
fragB = new FragmentB ();
list.ItemClick += (sender, e) => {
ListView item = sender as ListView;
int pos = item.CheckedItemPosition;
TextView t = (TextView) e.View.FindViewById(Resource.Id.textView1);
string mess = t.Text;
Bundle args = new Bundle();
args.PutString("message", mess);
transaction = SupportFragmentManager.BeginTransaction();
switch (pos){
case 0:
if(!fragA.IsVisible){
fragA.Arguments = args;
transaction.Replace(Resource.Id.frame, fragA);
}
break;
case 1:
if(!fragB.IsVisible){
fragB.Arguments = args;
transaction.Replace(Resource.Id.frame, fragB);
}
break;
}
transaction.Commit();
list.SetItemChecked(pos, true);
drawer.CloseDrawer(list);
};
mDrawerToggle = new Android.Support.V4.App.ActionBarDrawerToggle(this, drawer, Resource.Drawable.ic_drawer, Resource.String.drawer_open, Resource.String.drawer_close)
{
};
drawer.SetDrawerListener(mDrawerToggle);
SupportActionBar.SetDisplayHomeAsUpEnabled (true);
SupportActionBar.SetHomeButtonEnabled(true);
// Get our button from the layout resource,
// and attach an event to it
}
示例10: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
mDrawerListView = (ListView) inflater.Inflate(Resource.Layout.fragment_navigation_drawer, container, false);
mDrawerListView.SetItemChecked(mCurrentSelectedPosition, true);
mDrawerListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => selectItem(e.Position);
string[] title = new string[]
{
GetString(Resource.String.title_section1),
GetString(Resource.String.title_section2),
GetString(Resource.String.title_section3),
};
ArrayAdapter listAdapter = new ArrayAdapter(Activity, //this.getActionBar().ThemedContext,
Android.Resource.Layout.SimpleListItemActivated1, Android.Resource.Id.Text1, title);
mDrawerListView.SetAdapter(listAdapter);
mDrawerListView.SetItemChecked(mCurrentSelectedPosition, true);
return mDrawerListView;
}