w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Failed to load the LayoutLib: com.android.layoutlib.bridge.Bridge
Restart IDE Restart a computer Try to update ADT, SDK and Eclipse Plugin If that will not help reinstall ADT, SDK and Eclipse Plugin

Categories : Android

android.widget.ImageView cannot be cast to android.view.ViewGroup
I found where the problem was. I was trying to pass the resource id of the ImageView (R.id.photoView) used to build the fragment, not the actual fragment. Since this fragment was not created from a layout, I need to use its object reference and pass its containerViewId instead: // fragment previously created in MainActivity: PhotoFragment f = PhotoFragment.newInstance(); So to fix the problem I substituted: fragmentTransaction.replace(R.id.photoView, web_f); with: fragmentTransaction.replace(((ViewGroup)f.getView().getParent()).getId() , web_f);

Categories : Android

Android: get Viewgroup from the view?
Depending on which ViewGroup you are after, you can get the parent of your view and cast it to a ViewGroup: (ViewGroup)view.getParent() // this can be done to get any level in your view hierarchy or you can cast the view itself as a ViewGroup: (ViewGroup)view Basically, find the view you want in your view hierarchy and cast it to ViewGroup

Categories : Android

Android: Duplicating View element in the ViewGroup
Duplicating an object requires a good implementation of clone() method. I don't think Android's view classes do this well, so you may need to create a custom type of view that can produce a copy of itself. View class does have methods to save/restore state: with onSaveInstanceState () and onRestoreInstanceState() which you can use to copy View's state. Also, you will need to take care of event listeners registered on that view.

Categories : Android

android.widget.Button cannot be cast to android.view.View$OnKeyListener
The error is in the line buttonUpdate.setOnKeyListener((OnKeyListener) this.buttonUpdate);. Just as the error says, you cannot cast a button to an OnKeyListener. Explicit casting requires a relationship via class hierarchy - Button and OnKeyListener are not related (OnKeyListener is an interface). If you want to maintain your set up you can create a class that extends Button and Implements OnKeyListener. You will have to edit you xml to have your custom view in place of the button.

Categories : Java

Custom ViewGroup to make the view in viewgroup can slide cycle
Extends from ViewGroup and override dispatchDraw(), and draw the first/last page if is over scrolling It is something like: protected void computeCirculate(Canvas canvas) { if (isAllowCirculate()) { canvas.save(); canvas.translate(-getWidth() * getPageCount(), 0); drawPage(canvas, getPageCount() - 1); canvas.restore(); canvas.save(); canvas.translate(getWidth() * getPageCount(), 0); drawPage(canvas, 0); canvas.restore(); } } Updated: Please see my github project: Android_PagedView

Categories : Android

Android - do ViewGroup onDraw need to iterate through child view and call onDraw explicitly?
Did you overwrite onLayout? When Android lays out your ViewGroup, your ViewGroup is responsible for laying out the children. This code is from a custom ViewGroup that lays out all children on top of each other: @Override protected void onLayout(final boolean changed, final int l, final int t, final int r, final int b) { int count = this.getChildCount(); for (int i = 0; i < count; i++) { View child = this.getChildAt(i); child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight()); } } For completeness, the onMeasure override: @Override protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) { int parentWidth = MeasureSpec.getSize(widthMeasureSpec); int parentHeight = MeasureSpec.getSize(heightMeasureSpec);

Categories : Android

RuntimeException: Unable to start activity(MainActivity cannot be cast to android.view.View$OnClickListener)
In the MainActivity onCreate function, you are doing: drawBtn.setOnClickListener((OnClickListener)this); Here you are casing this to OnClickListener which is giving error. this gives you the activity context. You can trying to cast the activity context to OnClickListener, which is creating the casting exception. You can try just passing in the Activity's context like: drawBtn.setOnClickListener(this); Do the same for all the other buttons and don't cast it to OnClickListener. See if this changes something.

Categories : Java

Android gridview view cast exception
Do like this public TextView header(int message, View convertView){ TextView view = (TextView) convertView.findViewById(R.id.<textviewId>); // issue with cast exception if(view == null){ view = new TextView(mContext); } view.setText(underline(mContext.getResources().getString(message))); view.setTextSize(18); view.setTypeface(typeface, Typeface.BOLD_ITALIC); view.setTextColor(Color.WHITE); view.setGravity(Gravity.CENTER_VERTICAL); view.setLayoutParams(new AbsListView.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, mActionBarHeight - 15)); return view; }

Categories : Android

android.widget.EditText cannot be cast to com.businesscard.View.EditTextWithTextListener
When you have created a custom View make sure you define it as such in your XML. In your fragment_create_my_card.xml you should be referencing your view like this: <com.businesscard.View.EditTextWithTextListener android:id="@+id/cardPositionEdit" android:layout_height="wrap_content" android:layout_weight="wrap_content" /> EditText can't be cast to its subclass because it doesn't know anything about this subclass. EditTextWithTextListener is an EditText but EditText is not an EditTextWithTextListener.

Categories : Android

How to add dynamic layout in ViewGroup in android?
Try this ViewGroup parentView = (ViewGroup)SelectorView.your_context.getParent(); LayoutInflater layoutInflater = (LayoutInflater)activityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.ground_zoom , parentView);

Categories : Android

Android ViewGroup: what should I do in the onLayout() override?
In onLayout you need to call layout method on each child of this ViewGroup and provide desired position (relatively to parent) for them. You can check source code of FrameLayout (one of the simpliest subclasses of ViewGroup) to find out how it works. Although, if you don't need any "special" layouting, you have other options: Extend some another subclass of ViewGroup instead (FrameLayout for example) Use LayoutInflater if you just need your control to look exactly as in XML (which, I think, is exactly your case)

Categories : Android

Android | Get all children elements of a ViewGroup
(source) If you want to get all the child views, as well as the views within children ViewGroups, you must do it recursively, since there is no provision in the API to do this out of the box. private ArrayList<View> getAllChildren(View v) { if (!(v instanceof ViewGroup)) { ArrayList<View> viewArrayList = new ArrayList<View>(); viewArrayList.add(v); return viewArrayList; } ArrayList<View> result = new ArrayList<View>(); ViewGroup viewGroup = (ViewGroup) v; for (int i = 0; i < viewGroup.getChildCount(); i++) { View child = viewGroup.getChildAt(i); ArrayList<View> viewArrayList = new ArrayList<View>(); viewArrayList.add(v); viewArrayList.addAll(getAllChildren(child))

Categories : Android

Adding Layout to a ViewGroup Android
Try overriding the setContentView(int) instead of the onCreate(Bundle). Make sure your base layout XML has a ViewGroup (FrameLayout, for example) available to put each Activity's content. When overriding the setContentView(int), inflate your base layout first then inflate the Activity's layout and place the Activity's layout on the FrameLayout available.

Categories : Android

Android EditText exceeded it's parent viewgroup
You have given wrap_content for textview width whihc is causing this issue. Best would be to use a Relative layout there rather than Linear Layout. But in case you want to use LinearLayout only use match parent and rather than giving padding, use margin_left like below: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/comment" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" this will be adjusted programmatically android:layout_margin="5dp" android:background="@drawable/none" this will be adjusted programmatically android:ellipsize="none" an

Categories : Android

Android run time exception while using gestureImageView and ViewGroup
ViewGroup lout = (ViewGroup) findViewById(R.id.gestureImageView); Your gestureImageView is not a ViewGroup. Which Class does it extend from? Is it View? if yes, use View lout = (View) findViewById(R.id.gestureImageView);

Categories : Android

how to add an xml file dynamically multiple times for the same ViewGroup in android
Try this.. LayoutInflater vi= (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); TableRow tableRow = new TableRow(this); tableRow.setOrientation(TableRow.HORIZONTAL); for (int raw = 0; raw < 5; raw++) { View v = vi.inflate(R.layout.rowItem, null); // here I want to add the same rowitem.xml about four times in the same row tableRow .addView(v); }

Categories : Android

Bridge between Android-Java & JavaScript(Webview)
This is what you're looking for. Essentially you need to do the following: Create a JavaScriptInterface with methods that you want called. Add this to your webview by calling: webView.addJavascriptInterface(new MyJavaScriptInterface(this), "Android"); Add JS code on your webpage that calls out to Android.nameOfYourMethod().

Categories : Javascript

Why does Android Debug Bridge (adb) have to be restarted frequently?
I usually work with 2 computers, one is a High end computer playing windows 8 which I never got adb crashing or emulator running slow, but on my macmini with an i5 2415m and 2GB ram it crash a lot, but after I upgraded it to 5GB ram adb rarely get crashed, I can run 2 eclipses and 4 emulators and it rarely crashs. So what I mean, is that maybe adb is not finished and it has some issues which may be related to memory leaks or thread synchronization, But (again but) it is just a shot on my experience, actually it never bothered me much.

Categories : Android

Error using Map in app - com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment
Have you also changed the map in your XML layout? Should look like this: <fragment android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="8dp" />

Categories : Android

java.lang.ClassCastException: com.google.android.gms.common.images.e cannot be cast to android.content.ComponentCallbacks
Looks like this is a bug in Google Play game services ImageManager. We were using ImageManager loadImage() to load images for unlocked achievements. Because the class causing the exception is in the ImageManager package (android.gms.common.images) we tried updating the app to stop using ImageManager (switched to using APK image files). The bug has stopped, so I guess that's the cause

Categories : Android

Class cast exception cannot be cast to android.app.Fragment
Does your RouteDetailFragmentActivity extend the android.support.v4.app.FragmentActivity ? You have to be careful when using the support library. You have to remember to replace your usual Activity, Fragment, etc classes with the ones from the support library. You should read this page before continuing.

Categories : Android

Android Google Maps V2 Caused by: java.lang.ClassCastException: com.google.android.gms.maps.SupportMapFragment cannot be cast to android.app.Fragment
Switch super.onCreate first, then setContentView. This is because super.onCreate calls the framework's Activity.onCreate to allocate the resources needed to inflate any layouts. Hence , must be called before inflating any layouts, xml/programmatic.

Categories : Android

Android - Google Play Game Service, Could not find method android.view.View.getDisplay
Try these steps: Right click the project, and choose Properties Go to Java Build Path-Order and Export. Tick 'Android Private Libraries' if you put your libs there or tick on your libs. Then clean and build.

Categories : Android

ANDROID: Force Close - java.lang.ClassCastException: com.example.httpgetandroidexample.HttpGetAndroidExample cannot be cast to android.app
You try to run a "simple" java application on Android wich you CAN'T. Start by reading the android documentation . Your application must contain at least one Activity class and you can't put public static void main(String[] args) in any of your classes.

Categories : Java

ClassCastException ViewGroup$LayoutParams cannot be cast to ViewPager$LayoutParams
Do this way img.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)); UPDATE LayoutParams params = img.getLayoutParams(); params.width = LayoutParams.MATCH_PARENT; params.height = 100; img.setLayoutParams(params);

Categories : Android

Weblogic Bridge Message - Failure of server APACHE bridge:
You many not want to give Write to all (777) permission to /tmp/_wl_proxy directory. Check which userID apache is running under and only give writer permission to that userID. This could be also with tmp directory full.

Categories : Apache

Android.widget.RelativeLayout cannot be cast to android.widget.ImageView
Make sure in your code the compassView is ImageView variable only and try to access it as ImageView compassView = (ImageView) findViewById(R.id.visual_compass); And if everything is correct then try to clean and Build your project again from the menu Project-> clean. and Proejct-> Build.

Categories : Java

android.widget.Button cannot be cast to android.widget.EditText
It seems like either R.id.number1 or R.id.number2 is a Button. Check your XML and make sure it's an EditText. Edit: Original answer didn't work, but cleaning the project solved the problem.

Categories : Android

What are the advantages of creating a Fragment vs Extending a View or ViewGroup?
This is a bit of a reverse answer, explaining fragment use. In general you can do most things with Activities, but as the SDK supports fragments, many things will become more cumbersome (ViewPager is an example where fragment use is great). The advantages (of fragments): code encapsulation, reusable chunks of UI. The disadvantages (of fragments): more code (e.g. FragmentManager, FragmentTransaction). Your original use of activities was good, it's not a case where I would have switched to fragments. Let's say I designed a mobile phone app with two activities: ContactList and ContactDetails. So far so good, no reason to use fragments yet. If I wanted to support a larger device, it would behoove me to display both screens side by side. This is where fragments come in handy. In terms of

Categories : Android

Android CTS test case "android.view.cts.DisplayRefreshRateTest#testRefreshRate" failed
See if you have HW composer on, from my experience 4.2.2 is definitely an improvement from 4.1 in terms of graphics performance on Freescale. Do you get this with the prebuilt image from Freescale? You should verify that it happens with their image before running your own. I assume it passes with lower resolution?

Categories : Android

Dialog in fragment crashes android app. android.view.WindowsManager$BadTokenException
Change the following line: final Dialog dialog = new Dialog(getActivity().getApplicationContext()); to: final Dialog dialog = new Dialog(getActivity()); Dialogs cannot be instantiated with the application context as the two have a different life cycle: the dialog's life cycle is bound to that of the hosting Activity. A simple search here on SO would probably have brought that up too. For an explanation of the different Context flavours and when (not) to use which one, I'd recommend a read through possible mobile's blog post on this topic. It also contains a handy table for reference.

Categories : Java

How to navigate/view/edit android platform sources (AOSP) using Intellij IDE (Android Studio preferably)?
Well, first you have to install Android studio from here: http://developer.android.com/sdk/installing/studio.html Then, if you already have a project in Eclipse here is how you export it to Android Studio: http://developer.android.com/sdk/installing/migrate.html

Categories : Android

android: xml attribute android:onClick, why the method needs View parameter
So you know which View is calling the method. It's like implementing the OnClickListener for you activity, the method created is onClick(View v) (or arg0 depending on your Eclipse), defining it from xml is just specifiying a sort of listener for the View, and the method from the listener has that argument. Once you're in the method, you can do a switch for the id of the button, to perform different actions: public void myOnClickMethod(View v){ switch(v.getId()){ case R.id.button1: //Do something for button 1 break; case R.id.button2: //Do something for button 2 break; } } In short. Android just implements the OnClickListener for you when you define the android:onClick="myOnClickMethod" attribute.

Categories : Android

A view for text files in android like ImageView for Images in android
Use like this: if(filetype.toString().equals(".pdf")) { //place your pdf image imageview= (ImageView)findViewById(R.id.imageView); Drawable res = getResources().getDrawable(imageResource); imageView.setImageDrawable(res); } else if(filetype.toString().equals(".docs")) { //place your docs image imageview= (ImageView)findViewById(R.id.imageView); Drawable res = getResources().getDrawable(imageResource); imageView.setImageDrawable(res); }

Categories : Android

Android Maps App - caused by java.lang.classnotfoundexception android.view.fragment in loader dalvik.system
Your min sdk is 8. You shoud use SupportMapFragment. <fragment class="com.google.android.gms.maps.SupportMapFragment" ... Your class must extend FragmentActivity. Also make sure you imported the below import android.support.v4.app.FragmentActivity; import com.google.android.gms.maps.SupportMapFragment;

Categories : Android

Setting up android cast sdk
Download the Android Support package with the SDK Manager. It should include mediarouter and appcompat. Should also download the actual cast api: https://developers.google.com/cast/downloads/GoogleCastSdkAndroid-1.0.0.zip ... You can miss this link when reading the downloads page (at least that's what happened to me). Then import them all into Eclipse (File->Import), the support packages should be under sdk/extras/android/support/v7/mediarouter and sdk/extras/android/support/v7/appcompat. The cast package is wherever you saved it (I just put it in the sdk/ directory). The mediarouter depends on the appcompat, so you want to add it to the mediarouter project as a library. Head over to your application project and add the newly created mediarouter, appcompat and GoogleCastSdkAndroid package

Categories : Android

How to put two list view on same place in android layout in android?
Put both list views in a FrameLayout. That's it. The FrameLayout does no positioning of the contained views an just prints them one over the other. Just make sure, as you wrote, that at one time only of that views set to be visible.

Categories : Android

Android HashSet cannot be cast to LinkedHashSet
Change your code to use a basic HashSet: HashSet<String> planets = new LinkedHashSet<String>(); planets.add("Earth"); SharedPreferences prefs = getPreferences(0); prefs.edit().putStringSet("planets", planets).commit(); prefs = getPreferences(0); planets = prefs.getStringSet("planets", new LinkedHashSet<String>()); Side note: Keep in mind that SharedPreferences.getStringSet() is available in API11+ only. The reason why your Set is converted to a HashSet can be found in Android's source code: public Editor putStringSet(String key, Set<String> values) { synchronized (this) { mModified.put(key, (values == null) ? null : new HashSet<String>(values)); return this; } }

Categories : Java

can we cast EditText to TextView in android
yes you can do so because EditText is sublcass of TextView EditText is a thin veneer over TextView that configures itself to be editable. checkout dev link1 dev link2for detail

Categories : Android



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.