I'd spent quite a lot of time to find out the root cause of ClasscastException when we change the order of views in layout xml..
And found that if we do "Project --> Clean" in Eclipse the problem will be resolved.
Eclipse - is the culprit :)
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"></activity>
error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize').
AlertDialog.Builder alertDialog = new AlertDialog.Builder(Someclass.this);
builder.setMessage("Are you sure you want to quit?") alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent myIntent = new Intent(((Dialog) dialog).getContext(), Someclass2.class); startActivity(myIntent);
return;
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
// Do Nothing
}
alertDialog.show();
public class ImageViewOnclickListener implements OnClickListener {
private Context context;
public ImageViewOnclickListener(Context context) { this.context = context;
}
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, SomeActivity.class);
context.startActivity(intent);
}
}
protected void onCreate(...) {
setContentView(...);
((ImageView) findViewById(R.id.mybutton)).setOnClickListener(new ImageViewOnclickListener(this));
}
Hope this helps :)
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#C7B299"
android:dashWidth="10px"
android:dashGap="10px" />
</shape>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/dotted" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="left"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".60" />
<TextView
android:text="right"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".40" />
</LinearLayout>
You can replace the TextView with EditText or Button or whatever elements that fit your needs..
Note: Make sure to set thelayout_widthto0dpor your views may not be scaled properly.