Google+

Tuesday, September 20, 2011

How to Change Tab Name from Activity in Android

Tabs in the Android work with TabWidgets.
Contained in the tabwidget are relative layouts for each of your tabs which each contain an imageview and a textview.
Tab index will start from 0 and to access the Tab Contents use the following steps.
For Example. if you want to access title of tab
mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title);

the above statement will provide the view (TextView) at this position.

change the text of Tab

TextView v = ((TextView)mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title));


v.setText("My New Title");


Congratulations.
Your text of tab is changed.


Wednesday, September 14, 2011

How to Convert InputStream to String In Java

Here is the Simple method to convert InputStream Object to String Object.


Just Call this method and pass InputStream Object. it return the String






public static String convertStreamToString(InputStream is) throws Exception
{
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();
    String line = null;

    while ((line = reader.readLine()) != null) {
        sb.append(line);
    }

    is.close();

    return sb.toString();
}

Tuesday, September 13, 2011

How to get Multiple Select List-Box in PHP

Multiple ListBox in HTML will send the array of selected item. 
 
 
 
Sample PHP Code to access the Multiple Selected List-Box Values.
 
<html>
<head>
<title>List Box Form Data</title>
</head>
<body>
     <h3>List Box Form Data</h3>
     <p>Form data passed from the form</p>
    
    <?php
        echo "<p>select: " . $_POST['select']."</p>\n"; 
        echo "<p>listbox: " . $_POST['listbox'] . "</p>\n";
        $values = $_POST['listmultiple'];
        echo "<p>listmultiple: ";
        foreach ($values as $a){
            echo $a;
        }
        echo "</p>\n";
    ?>
</body>
</html>

Friday, September 9, 2011

How to find Android Unique Device ID or UDID - Part 1

Here is the Simple Statement to find Android Device ID which return a String.


String udid = Secure.getString(getContentResolver(), Secure.ANDROID_ID)




Please Note : 
ANDROID_ID is a 64-bit number (as a hex string) that is RANDOMLY GENERATED on the device's first boot and should remain constant for the lifetime of the device.(The value may change if a factory reset is performed on the device.)

Source : Android Documentation
Google+