Tags down


prevent listview to lose selected item

By : user3851721
Date : October 15 2020, 11:12 PM
Hope this helps The listview control has a HideSelection property that defaults to True. Make it False and you're good to go... in some cases this is enough.
code :

Share : facebook icon twitter icon

Android ListView get last selected item and get last selected item from other ListView in onItemClick

By : Lakky
Date : March 29 2020, 07:55 AM
around this issue I have two ListView. Both of them use the same adapter. I want to choose items mutually exclusive from these two lists. For every item in list view I have layout , I resolve my problem. Here my code
code :
 private List<TypeOfSupport> quoteToCashEngagementsList;
        private List<TypeOfSupport> pointRequestsList;
        private int positionCurItemInQuoteToCashList = -1;
        private int positionCurItemInPointRequestList = -1;

        protected void onCreate(Bundle savedInstanceState) {

            Resources resources = getResources();

            final TypeOfSupportAdapter quoteToCashAdapter = new TypeOfSupportAdapter(SelectionTypeOfSupport.this, R.layout.lv_type_of_support, quoteToCashEngagementsList);
            final TypeOfSupportAdapter pointRequestsAdapter = new TypeOfSupportAdapter(SelectionTypeOfSupport.this, R.layout.lv_type_of_support, pointRequestsList);
            final ListView quoteToCashListView = (ListView) findViewById(R.id.quote_to_cash_list);
            quoteToCashListView.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
                    if(positionCurItemInQuoteToCashList != -1){
                    if(positionCurItemInPointRequestList != -1){
                    positionCurItemInQuoteToCashList = position;

                    positionCurItemInPointRequestList = -1;

            ListView pointRequestsListView = (ListView) findViewById(R.id.point_requests_list);
            pointRequestsListView.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
                    if(positionCurItemInPointRequestList != -1){
                    if(positionCurItemInQuoteToCashList != -1){

                    positionCurItemInPointRequestList = position;

                    positionCurItemInQuoteToCashList = -1;


private class TypeOfSupportAdapter extends ArrayAdapter<TypeOfSupport> {
        private Context context;
        private List<TypeOfSupport> typeOfSupportList;
        private int resourceId;

        public TypeOfSupportAdapter(Context context, int resource, List<TypeOfSupport> objects) {
            super(context, resource, objects);
            this.context = context;
            this.resourceId = resource;
            this.typeOfSupportList = objects;

        public TypeOfSupport getItem(int position) {
            return typeOfSupportList.get(position);

        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
            View rowView = layoutInflater.inflate(resourceId, parent, false);

            TypeOfSupport curTypeOfSupport = typeOfSupportList.get(position);
            TextView typeOfSupport = (TextView) rowView.findViewById(R.id.type_of_support);
            ImageView checkImage = (ImageView) rowView.findViewById(R.id.img_checked_type);
            } else {

            return rowView;

Android prevent listview changing selected item when gaining focus

By : CAP
Date : March 29 2020, 07:55 AM
hope this fix your issue so you can memorize necessary positions in both lists and change background for this concrete items. and redefine public boolean onKeyDown(int keyCode, KeyEvent event)
so if you need i should write code

How to keep gridview (or ListView) item selected and not lose the selection because of recycling

By : user3255123
Date : March 29 2020, 07:55 AM
will be helpful for those in need The trick is to not worry about saving the view's state. Instead, save/change the state of underlying data. So if a position is selected, place the position in a data structure (usually a SparseBooleanArray). When this position comes back into view, i.e. getView() is called for this position, update the view properties accordingly.

How to prevent listview from jumping to selected/focused row on item.count change?

By : neriberto
Date : March 29 2020, 07:55 AM
help you fix your problem The problem is that the TListItems.Count property setter calls ListView_SetItemCountEx() without the LVSICF_NOSCROLL flag:
code :
procedure TListItems.SetCount(Value: Integer);
  if Value <> 0 then
    ListView_SetItemCountEx(Handle, Value, LVSICF_NOINVALIDATEALL)
    ListView_SetItemCountEx(Handle, Value, 0);
  ..., CommCtrl;

procedure TForm1.Timer1Timer(Sender: TObject);
  //ListView1.Items.Count := ListView1.Items.Count + 10;
  ListView_SetItemCountEx(ListView1.Handle, ListView1.Items.Count + 10, LVSICF_NOINVALIDATEALL or LVSICF_NOSCROLL);

Listview's selected item not in sync with the selected state of an item unless my mouse pointer is released after select

By : user2822342
Date : March 29 2020, 07:55 AM
will help you Just figured out a way to handle this.
Add a pointer pressed event to the textblock. Empty the selected item to null in the pointer pressed event. This immediately clears the selected state of item when the pointer is in pressed state and since, the selection changed event gets triggered only after this event, clearing in pressed state doesn't affect the new item selected. Get the data context from the pointer pressed event and do the needed operations.
code :
<ListView x:Name="TestingList" 
                              ItemsSource="{x:Bind TestListing.Details}"                               
                              SelectedItem="{x:Bind TestListing.DefaultSelected,Mode=TwoWay}"    
                            <DataTemplate x:DataType="test:TestingName">
                                <TextBlock Margin="42,5,0,0" Style="{StaticResource TextStyle}"  PointerPressed="Test_PointerPressed" 
                                           Text="{x:Bind Name}" TextWrapping="Wrap"/>
private void Test_PointerPressed(object sender, PointerRoutedEventArgs e)
            TestingList.SelectedItem = null;
            TestingName x = e.OriginalSource as TextBlock).DataContext as TestingName);

Related Posts Related Posts :
  • .NET Remoting client config creates local object, not remote
  • Is there a possibility to differ virtual printer from physical one?
  • Print barcode which has high scan rate
  • Query string value having "&"
  • Which is best for perfomance?
  • Can we make overloaded controller method in ASP .NET MVC
  • Nested loop in StringTemplate
  • How to get SSID and RSSI for Win7 using C#
  • Send messages to applications on the network (.Net)
  • Detect and prevent/delay windows mobile power off
  • How X509 Certificate renewal does not impact the code?
  • Silverlight: How to make my custom control act like a button
  • C# basic Dictionary Ordering Just need to clear an error
  • Common c# idioms including coalesce ?? operator
  • Why Does Thread.CurrentThread.CurrentCulture Change between Page Rendering and HttpModule.PostRequestHandlerExecute?
  • COM Exception 0x8004005
  • How do I show a message box from inside a class in a class library?
  • LINQ Distinct Query
  • Issue with number guessing game c#
  • Usage of a using statement
  • Building a forms system using DDD
  • How can I programmatically tell in C# if an unmanaged lib is x86 or x64?
  • How do I get an Excel range using row and column numbers in VSTO / C#?
  • .NET 4.0 Memory Mapped Files Performance
  • db4o Indexing problem - Not Working? Poor performance?
  • Realtime Console Output Redirection using Process
  • How do C# Linq extension methods perform equality comparison?
  • internal RSS feed not working with webClient object
  • C# / Silverlight / WPF / Fast rendering lots of circles
  • how to bind table from database to checkedListBox?
  • Is it ok to catch all exception types if you rethrow them wrapped another exception?
  • Print image in .Net winform
  • Problem with StandardOutput stream in async mode
  • Partially implement an Interface
  • How to extract html links from html file in C#?
  • Windows seems to lose track of .NET application
  • Do .NET 3/4 Permits Events to be Binary De/Serialized?
  • Static Methods in ASP.NET
  • How to set an Image fit to width of ScrollViewer
  • Can C# compiler be configured to give warning when explicit cast may cause data loss?
  • How can I strip html tags in C#
  • How do i unit test a website with no backend class?
  • Is there tool that can port or compile excel VBA code to C#?
  • NUnit conflict with Debug.Assert
  • C# Adding a long string to combobox
  • Creating Wizards for Windows Forms in C#
  • How to access the main windows handle once the child window exits in a process in C#
  • Mock AutoMapper Mapper.Map call using Moq
  • Copy C# object along with reference
  • Script for changing fonts in a Word document
  • 2 equal byte[] does not return true
  • Image capture of Windows mobile 5.0 camera using C# winform
  • Magento 1.4 productIdentifierType
  • File locks when using file.move in c#...how can I stop or fix this
  • Is there a framework that works the way like updating a virus definition database?
  • How can I make use of Visual Studio's regular expression to replace multiple lines of code?
  • Configuring Threadpool Max Threads via app.config?
  • C# thread dispatcher
  • Linkbutton inside Repeater for paging ASP.Net
  • How can I perform division in a program, digit by digit?
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org