Genymotion not workin after windows 10 update

**First update to latest version of Virtual box

Then—

Go to :=>
Control Panel\Network and Internet\Network and Sharing Center\Change adapter setting

  1. Select Ethernet(VirtualBox Host-Only Ethernet …..)
  2. Right click on VirtualBox Host only adapter that created
  3. Choose properties
  4. Check “VirtualBox NDIS6 Bridged Networking driver”
  5. Press Ok
  6. Right click on Ethernet  and Disable it
  7. Right click on Ethernet  and Enable it
    *** Here we go to use Genymotion***

Image

Not able to write on Sdcard in emulator

Getting error when trying to push file on sdcard in emulator or not able to write file on sdcard in emulator

Failed to push selection: Read-only file system

——————

C:\Documents and Settings\<adminstrator>\.android\avd

OR

C:\Documents and Settings\Pankaj\.android\avd

==>

take 'properties' of your avd folder (there is a folder for each of the avd’s)

uncheck 'Read only' -> OK 

 

Not able to find any xml layout in activity on setContentView

When trying to get xml layout in activity  on setContentView(R.layout.    )  ==not able to find the layout

=> Reason and solution

1) the layout might some error so instead of repairing it delete and again create it and clean project. ( Specially if you are not getting particular layout)

2) when we are accessing layout to set in Activity and not able to find any layout then its an issue of selection for proper package            ==>  setContentView(R.) = after pressing  r.  when we select layout then select it carefully because it shows                                        default  1) layout-android.R  and  2)layout-your package name.R    so always select layout with your package

 layout ====  2)layout-your package name.R     then you can see all layout

=== setContentView(R.layout.xml_layout) 

 

java.lang.IndexOutOfBoundsException: Invalid index .., size is .. when setting value to arraylist spinner at position

java.lang.IndexOutOfBoundsException: Invalid index  .., size is  ..

when setting value to arraylist spinner at position

 Error In Log==>

06-27 14:46:01.821: E/AndroidRuntime(20824): FATAL EXCEPTION: main
06-27 14:46:01.821: E/AndroidRuntime(20824): java.lang.IndexOutOfBoundsException: Invalid index 6, size is 4
06-27 14:46:01.821: E/AndroidRuntime(20824): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
06-27 14:46:01.821: E/AndroidRuntime(20824): at java.util.ArrayList.get(ArrayList.java:304)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:337)
06-27 14:46:01.821: E/AndroidRuntime(20824): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:390)
 
Solution:=>  
String name=”Pankaj”;
 Check value in arraylist using => arrayList.indexOf()
and take out the position of value from arraylist.=>
int pos= arrayList.indexOf(name);
 Set Position in Spinner :=>
 spinner.setSelection(pos);
 -------------------------------------------------
int pos= arrayList.indexOf(name);
spinner.setSelection(pos);

 

Resource$NotFoundException when Setting value to TextView

when we pass or set an value (integer,float,double) anything except string that time we get that exception.

Android assume it as resource id that’s why this exception occurs.

  • Solution: Try converting those value to String like
  1. textview.settext(String.valueof(  ));
  2. textview.settext(Integer.toString());

Scrollabale listview in both direction with header using Horizontal scrollview

In this code i have used two linear layout in Horizontal Scrollview.=>[

first Outerlinear layout(orientation:vertical)  contain==>[ inner linear layout(orientation:horizontal) which includes textview’s which work as header and scroll with listview.] that listview is in outer layout after closing inner layout.]

 

<HorizontalScrollView
            android:layout_width=”wrap_content”
            android:layout_height=”wrap_content”
             android:layout_alignParentLeft = “true”
        android:layout_alignParentRight = “true”>

            <LinearLayout
                android:layout_width=”match_parent”
                android:layout_height=”wrap_content”
                 android:orientation=”vertical” >
        <LinearLayout
        android:layout_width=”match_parent”
        android:layout_height=”wrap_content”
            android:orientation=”horizontal”   >
                <TextView
                    android:id=”@+id/textView7″
                    android:layout_width=”85dp”
                    android:layout_height=”wrap_content”
                    android:layout_marginLeft=”5dp”
                    android:text=”Deal_NO”
                    android:textAppearance=”?android:attr/textAppearanceLarge” />

                <TextView
                    android:id=”@+id/textView8″
                    android:layout_width=”190dp”
                    android:layout_height=”wrap_content”
                    android:layout_marginLeft=”15dp”
                    android:text=”Buyer_Party_Name”
                    android:textAppearance=”?android:attr/textAppearanceLarge” />

                <TextView
                    android:id=”@+id/textView9″
                    android:layout_width=”190dp”
                    android:layout_height=”wrap_content”
                    android:layout_marginLeft=”15dp”
                    android:text=”Seller_Party_Name”
                    android:textAppearance=”?android:attr/textAppearanceLarge” />

                <TextView
                    android:id=”@+id/textView09″
                    android:layout_width=”130dp”
                    android:layout_height=”wrap_content”
                    android:layout_marginLeft=”11dp”
                    android:text=”Item_Name”
                    android:textAppearance=”?android:attr/textAppearanceLarge” />

                <TextView
                    android:id=”@+id/textView10″
                    android:layout_width=”135dp”
                    android:layout_height=”wrap_content”
                    android:layout_marginLeft=”8dp”
                    android:text=”Deal_Amount”
                    android:textAppearance=”?android:attr/textAppearanceLarge” />

                <TextView
                    android:id=”@+id/textView12″
                    android:layout_width=”125dp”
                    android:layout_height=”wrap_content”
                    android:layout_marginLeft=”5dp”
                    android:text=”Deal_Date”
                    android:textAppearance=”?android:attr/textAppearanceLarge” />

                <TextView
                    android:id=”@+id/textView014″
                    android:layout_width=”135dp”
                    android:layout_height=”wrap_content”
                    android:layout_marginLeft=”10dp”
                    android:text=”Loading_Date”
                    android:textAppearance=”?android:attr/textAppearanceLarge” />

                <TextView
                    android:id=”@+id/textView14″
                    android:layout_width=”160dp”
                    android:layout_height=”wrap_content”
                    android:layout_marginLeft=”10dp”
                    android:text=”Unloading_Date”
                    android:textAppearance=”?android:attr/textAppearanceLarge” />
            </LinearLayout>
            
       

        <View
            android:layout_width=”fill_parent”
            android:layout_height=”3dp”
            android:layout_marginBottom=”5dp”
            android:layout_marginTop=”5dp”
            android:background=”@android:color/black” />

        <ListView
            android:id=”@+id/OviewListView1″
            android:layout_width=”fill_parent”
            android:layout_height=”200dp” >
        </ListView>
        </LinearLayout>
         </HorizontalScrollView>

Alert Dialogebox with choice option and Display previouse selected value using sharedpreferences

use alertDialogebox with multiple option  where you need to select any one to make choice.

As well to get previous selected option value in alertDialogebox instead of default first selected option.   you need to store selected value into sharedpreference file ,and check each time  when you load this page .

like==>

class Alert extent Activity{

int j,m,savedState,languageLocalization;

public void onCreate(Bundle savedInstanceState) {

SharedPreferences();//check before loading layout
super.onCreate(savedInstanceState);
//
setContentView(R.layout.home_page1);

final CharSequence[] items = { “English”, “Hindi”,
“Marathi” };

AlertDialog.Builder builder = new AlertDialog.Builder(Setting.this);
builder.setTitle(“Languages”);

builder.setCancelable(true);

/* even without making any choice it can be cancel .. otherwise use

setCancelable (false)  for compulsory selction*/

builder.setSingleChoiceItems(items, j,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int item) {
j = item;
SharedPreferences languageSelect = getSharedPreferences(
“MY_SHARED_PREF”, MODE_PRIVATE);
SharedPreferences.Editor prefsEditor = languageSelect
.edit();

if (j == 0) {
CharSequence text = “English”;
Toast.makeText(getBaseContext(), text,
Toast.LENGTH_SHORT).show();
prefsEditor.putInt(“savedState”, j);
prefsEditor.commit();
SharedPreferences();
refresh();
}
if (j == 1) {
CharSequence text1 = “Hindi”;
Toast.makeText(getBaseContext(), text1,
Toast.LENGTH_SHORT).show();

prefsEditor.putInt(“savedState”, j);
prefsEditor.commit();
SharedPreferences();
refresh();
}
if (j == 2) {
CharSequence text2 = “Marathi”;
Toast.makeText(getBaseContext(), text2,
Toast.LENGTH_SHORT).show();
prefsEditor.putInt(“savedState”, j);
prefsEditor.commit();
SharedPreferences();
refresh();
}

}

});

builder.setNegativeButton(“cancel”,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),
Setting.class).setFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
startActivity(intent);
}
});

AlertDialog alert = builder.create();
alert.show();

}

private void SharedPreferences() {

SharedPreferences languageStateSave = getSharedPreferences(
“MY_SHARED_PREF”, MODE_PRIVATE);
languageLocalization = languageStateSave.getInt(“savedState”, 0);
//System.out.println(“Check Langauge    ” + languageLocalization);
m = languageLocalization;
System.out.println(“changed Lan:   ” + m);
j=m; //here we pass the previous selected value  which we use in alertDialogebox to set the selected choice….check “j” in alertDialogebox code

}

}

//you can find shared preferance file in data/data/application package folder/shared-prefs/