R
R
releyshic2021-09-04 18:47:07
Android
releyshic, 2021-09-04 18:47:07

How to access a field/property of a BlockList: Activity view window, given an Activity reference passed (Xamarin.Android)?

It is necessary for Xamarin.Android.
How to refer to lblListHeader, lvExp in the method public override View GetGroupView ???

public class BlockList : Activity
{            
        ExpandableListAdapter listAdapter;
        ExpandableListView expListView;

        public ExpandableListView lvExp;
        public TextView lblListHeader;
        public TextView lblListItem;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.BlockList); // загружаем наш Активити (страницу xml) из папки Resources.Layout
...
            listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
            expListView.SetAdapter(listAdapter);
}


public class ExpandableListAdapter : BaseExpandableListAdapter
    {
        private Activity _context;
        private List<string> _listDataHeader; // header titles
                                              // child data in format of header title, child title
        private Dictionary<string, List<string>> _listDataChild;

        public ExpandableListAdapter(Activity context, List<string> listDataHeader, Dictionary<String, List<string>> listChildData)
        {
            _context = context;
            _listDataHeader = listDataHeader;
            _listDataChild = listChildData;
        }
        public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
        {
...     <i><b>Как здесь обратиться к lblListHeader, lvExp ???</b></i>
         }


Or do you need to transfer the BlockList itself?

2 question: how to access BlockList from MainPage ?
public class MainActivity : AppCompatActivity
    {
        public static MainActivity MainActivityInstance { get; private set; }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            MainActivityInstance = this;

            // Create your application here
            Intent intent = new Intent(this, typeof(BlockList)); // загружаем наш класс для Активити typeof(RetryPage)
            StartActivity(intent);


All this is needed without XAMl. It's so clear with him

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question