Tuesday, August 23, 2022

How to upgrade Git on Windows to the latest version

Upgrading Git on Windows is a simple process that can be accomplished in a few minutes. You shouldn't need to take any special action to update your Git client software; simply update the program as instructed in the installation message.

You can find the version of your installed git with the below command:
git --version:


To upgrade the git to latest version from Git 2.16.1(2) you can use the below command:

C:\> git update-git-for-windows

In versions between 2.14.2 and 2.16.1, the command was:


C:\> git update

This command does not exist in Git 2.13 and before. For that you need to use the below method:

You can use the latest stable release of Git on Windows in its original form or you can use the latest version of Git for Windows. Downloading the latest version may take some time, depending on the server bandwidth. Once it is downloaded, run the installer and follow step-by-step instructions to install Git on Windows.

You can download it from: https://git-scm.com/downloads

This will automatically finds the existing version and upgrades it to latest version.

Git for Windows is the best way to get started with version control on Windows. 
The Git for Windows installer includes everything you need to get started on Windows. The installer does not include a Git server, you will need to install your own Git server if you wish to distribute code using Git. To install an existing standalone Git server or an old version of JGit, see the JGit installation instructions.. The above process is for git client.

If you already have the latest version it does nothing, in which case you can manually run the installer to reinstall.


C:\> git update-git-for-windows
Git for Windows 2.17.0.windows.1 (64bit)
Up to date

Sunday, August 21, 2022

Way to fix “cannot resolve symbol R” in Android Studio

The problem "Cannot resolve symbol R" may have appeared frequently while you were developing android projects. The R is red when you initially create a new activity or class, and Android Studio informs you that it cannot identify the sign R. To import the necessary files that are missing, simply hover over the R symbol and click Alt + Enter. But doing so does not correct this mistake. The resource is represented by the letter R. The build process' inability to sync Resource files with your projects is the cause of this problem. This typically occurs as a result of the project's faulty construction.

When you move your code to another computer or email the code to another user, you frequently get the problem "Cannot resolve symbol R" in Android Studio. When an application cannot be run, the "R" becomes red and throws an error. The "R cannot be resolved" error most frequently occurs when one or more of your resource files are problematic. You are unable to create your application because of this issue. We must therefore find a solution to this problem because a simple restart or pressing Alt+Enter won't make it go away.

To solve this problem, the easiest way is to Gradle Sync by clicking on  File > Sync project with Gradle Files.


After this you can clean and rebuild the project and the error is gone. !!!

Friday, August 19, 2022

Adding a scrollbar to listview in android

Listview Displays a vertically-scrollable collection of views, where each view is positioned immediately below the previous view in the list. For a more modern, flexible, and performant approach to displaying lists, use RecyclerView.

To display a list, you can include a list view in your layout XML file:

<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
To make it scrollable you need to add: 
android:scrollbars=”vertical”
xml file looks as below: 
<?xml version="1.0" encoding="utf-8"?>
<relativeLayout
android:id="@+id/widget32"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
    <listView
            android:id="@+id/listview"
            android:scrollbars="vertical"
            android:layout_width="fill_parent"
            android:layout_height="200dip"
            android:layout_gravity="fill_vertical"
            android:layout_alignParentTop="true"
            >
        </listView>
 
</relativeLayout>
Now the java file snippet looks like: 
   
package com.marutsoft.exampleListview;
 
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
 
public class Example extends Activity
{
    /** Called when the activity is first created. */
    ListView list;
    private List<string> List_file;
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        List_file =new ArrayList<string>();
        list = (ListView)findViewById(R.id.listview);
 
        CreateListView();
    }
    private void CreateListView()
    {
        
         List_file.add("Google");
         List_file.add("Android");
         List_file.add("Apple");
         List_file.add("iPhone");
         
         //Create an adapter for the listView and add the ArrayList to the adapter.
         list.setAdapter(new ArrayAdapter<string>(Example.this, android.R.layout.simple_list_item_1,List_file));
         list.setOnItemClickListener(new OnItemClickListener()
           {
                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3)
                {
                    
                }
           });
    }
}