Showing posts with label Android phone not detect while run in android studio. Show all posts
Showing posts with label Android phone not detect while run in android studio. Show all posts

Saturday, November 4, 2017

Android Phone Not Detect While Run in Android studio

Android Phone Not Detect While Run in Android studio

Hi Android Guys ! Today  we are going to see about mobile devices not detected in android studio While run the project , then see how to solve .

Most of the members ask how to resolve the problem .

Step 1
Find the android device model , Setting > about device > Model number (Android  Device)

Step 2
In google Search > type device name followed by Usb driver then download the UsbDriver

Step 3
Right Click, My computer > properties >System Window open then see the left panel

In Left Panel > Device Manager >see Other Devices >Unknown Devices







Step 4

Right Click the unknown devices > properties > Unknown device properties open.Then the Open dialog see the Update Driver button, Click the button 

Step 5

Then Click "Let me pick from a list of device driver on my computer"





Then Update driver software, Android studio will sure detect mobile phone will run the project..

Sunday, October 29, 2017

TabHost and TabWidget In Android

TabHost and TabWidget In Android:

Today we are going to see about Tabhost and TabWidget it's very easy concept.......

Step :1

First Create Project in android studio, Add TabHost in XML Activity Layout.
In following folder.

res/layout/activity_main.xml



<LinearLayout 

   xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TabHost

        android:id="@+id/tabHost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">

        <LinearLayout

            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TabWidget

                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></TabWidget>

            <FrameLayout

                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout

                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#ffc916"
                    android:orientation="vertical">

                    <TextView

                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="First" />

                </LinearLayout>


                <LinearLayout

                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#da8200"
                    android:orientation="vertical">

                    <TextView

                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="Second" />
                </LinearLayout>

                <LinearLayout

                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#5b89ff"
                    android:orientation="vertical">

                    <TextView

                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:text="Third" />
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>

</LinearLayout>




Step 2


In MainActivity ,Inside oncreate() method.


1.Create TabHost object using getTabHost().

2.Create tabSpec object.
3.Set Indicator for the Spec.
4.Set Content for the Spec.


These fours steps to achieve tab in android.

Example

TabHost tabhost = getTabHost();
//Tab
TabSpec firstTabSpec = tabHost.newTabSpec("First");
//Set title and icon for the tab
firstTabSpec .setIndicator("First",R.drawable.icon);
Intent firstIntent = new Intent(this,FirstActivity.class);
firstTabSpec.setContent(firstIntent);

//finally add to tabhost

tabhost.addTab(firstIntent);