[android-developers] Custom view for Tablayout's items
Hi everyone! I created a custom view for TabLayout items, where I have a pictured and the text below it (ImageButton + TextView). Original tabs have only text and when you tap on one tab, you can see some fade effect by default in gray color which gives you the feeling that you tapped on the tab. Since I made the custom view for tabs, the fade effect is still there, but only when I click somewhere around the picture layer and not when I hit the picture layer. The fragment is switched because I made the click event that switches to proper fragment, because by default the switch wasn't working while clicking on imageButton. Thank you in advance! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/93e93844-ce56-43f1-967a-6407446fb804%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[android-developers] Custom view rendering issue
Hi, I am writing a custom view and for optimization purposes, I draw some static part of the view in a Bitmap. Unfortunately, the quality of the rendering when using an offscreen bitmap is noticeably less compared to rendering into the view's canvas bitmap. Here are two screenshots showing the difference Rendering into view's Canvas: https://lh5.googleusercontent.com/-wSjtLmhUgz8/UQZV96LTo6I/AEM/r9saff_8dlM/s1600/01_view_canvas.png Rendering into a Bitmap Canvas https://lh3.googleusercontent.com/-jVuFcXhAf7g/UQZWK7NBNfI/AEU/0AfCGfQMudU/s1600/02_bitmap_canvas.png The difference is most noticeable at the horizontal black line. The anti-aliasing algorithm seems to affect more pixels (is wider). The drawing code is the same in both cases, and the offscreen canvas is created like this final Bitmap tempBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_); final Canvas tempCanvas = new Canvas(tempBitmap); Any ideas on how to get the same rendering in the offscreen canvas as in the view's ? Thank you -- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups Android Developers group. To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[android-developers] Custom View
How to create a view like this (Please find the attached image) , which layout I want to use ? When we click on + button i need to change the text dynamically. Can you please share all your thought on how to do this ? Regards, Jovish -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=enattachment: customView.PNG
[android-developers] custom view in a row of listview
Hi friends, How to create a custom view for a particular row in listview in android. -- Regards, Vani Reddy -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] custom view in a row of listview
Read this.. it's a valuable resource: http://www.vogella.de/articles/AndroidListView/article.html 2011/8/16 vani reddy vani.reddy.bl...@gmail.com Hi friends, How to create a custom view for a particular row in listview in android. -- Regards, Vani Reddy -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] custom view in a row of listview
Hi R U saying about the custom list view(each row of a list view is different from normal litstview, it have some images , colors etc) or clicking a particular row of a list , u need a different view to display plse make more clear/// thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] custom view in a row of listview
Hi, In a particular row of listview i want a custom view. For ex: in getView() method we have @Override public View getView(int position, View convertView, ViewGroup parent) { View retval = LayoutInflater.from(parent.getContext()).inflate( R.layout.listin_list, null); TextView title = (TextView) retval.findViewById(R.id.text); ImagevIew img =(Imageview)retval.findViewById(R.id.image); img.setImageResource(mThimdIds[posiiton]); customGalleryView custom =(customGalleryView )retval.findViewById(R.id.custom); custom.setAdapter(new ImageAdapter(this)); /// I am not able to do this ... title.setText(CATEGORY); return retval; } in my listin_list.xml i have ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/android; android:layout_width=fill_parent android:orientation=vertical android:layout_height=wrap_content TextView android:id=@+id/text android:textColor=#000 android:layout_width=fill_parent android:layout_height=wrap_content/ ImageView android:id=@+id/image android:textColor=#000 android:layout_width=wrap_content android:layout_height=wrap_content/ com.android.project.customGalleryView android:id=@+id/custom android:layout_width=wrap_content android:layout_height=wrap_content/ /LinearLayout How to inflate the customGalleryView in listin_list.xml. and setAdapter(new ImageAdapter(this)); On Tue, Aug 16, 2011 at 6:40 PM, Ratheesh Valamchuzhy android...@gmail.comwrote: Hi R U saying about the custom list view(each row of a list view is different from normal litstview, it have some images , colors etc) or clicking a particular row of a list , u need a different view to display plse make more clear/// thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Regards, Vani Reddy -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom View
Hello all, I'm working on a custom view and I have some problems trying to define some custom XML attributes. Here is part of my definitions: declare-styleable name=ViewUpDown attr name=step format=float / attr name=value format=float / attr name=unit format=string / attr name=title format=string / /declare-styleable declare-styleable name=ViewSelect attr name=items format=string / attr name=title format=string / /declare-styleable 1- Both have the attribute title, they are distinct view so I think The is no conflit but is. I get an error that says title has already defined on the second title. 2- the attribute items on ViewSelect should be a string array? I tried some options like: string-array or string[], but none worked. I been looking for a list of valid options but without luck. Any tip? Thank you! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom view and horizontal scrolling
I am facing two issue here. 1. If I create HorizontalScrollView and add custom view using HorizontalScrollView.addview() the application did not crash but my custom view is not display. It onDraw never gets called. 2. In other approach if I use XML and specify my custom view as child of HorizontalScrollView then the application crashes. And I could not figure out how to provide agrument if to custom view constructor when using XML approach. Regards, Yasir -- Forwarded message -- From: Dianne Hackborn hack...@android.com Date: Wed, Apr 27, 2011 at 5:47 AM Subject: Re: Custom view and horizontal scrolling To: android-platf...@googlegroups.com You need to make the view that is a child of the scroll view actually larger in size than the scroll view so there is something to scroll. Further questions on this would best be asked on android-developers or StackOverflow. On Tue, Apr 26, 2011 at 7:03 PM, yasir perwez jugnoya...@gmail.com wrote: I have a custom view derived from View class. Where I am drawing a graph using Canvas and I have implemented onDraw. This view is horizontally bigger then screen. I want to make is scrollable horizontally. The custom take sevaral argument it it constructor. I tried various option Like make layout xml and ?xml version=1.0 encoding=UTF-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent HorizontalScrollView android:id=@+id/scroll android:layout_width=fill_parent android:layout_height=fill_parent android:fillViewport=true com.yasir.canvasTest.GraphView android:layout_width=fill_parent android:layout_height=fill_parent/ /HorizontalScrollView /LinearLayout then in onCreate of Activity setContentView(R.layout.horscroll); Question :- How will I specify argument to the contructor of my custom view. I also tried creating HorizontalScrollView and adding custom view using HorizontalScrollView.addview() the application did not crash but my custom view is not display. It onDraw never gets called. Please suggest me how to solve this issue. -- Yasir Perwez -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom view and java.lang.NoSuchMethodException for android.view.InflateException
Hello, I've take part of the ColorPicker code from APIDemo to make a custom View in a separate class. Just now I can create this view and set as content from code and it works. The problem comes when I want to do it from xml file. The error says that it cannot find the 2 argument's constructor for the class, but it is in the class... So I don't understand why am I getting this error... This is the main.xml ?xml version=1.0 encoding=utf-8? com.mipixel.rgblamp.ColorPickerView xmlns:android=http://schemas.android.com/apk/res/android; android:id=@+id/colorPicker android:layout_height=wrap_content android:layout_width=wrap_content android:layout_gravity=center_horizontal|center / Here is the ColorPickerView.java: http://pastebin.com/t7Rd9KLJ And here the activity code: http://pastebin.com/rwSB0dTk This is the error LogCat: 04-24 04:03:58.231: ERROR/AndroidRuntime(12529): Uncaught handler: thread main exiting due to uncaught exception 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mipixel.rgblamp/com.mipixel.rgblamp.RGBLamp}: android.view.InflateException: Binary XML file line #2: Error inflating class com.mipixel.rgblamp.ColorPickerView 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2503) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2519) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.app.ActivityThread.access$2200(ActivityThread.java:123) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.os.Handler.dispatchMessage(Handler.java:99) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.os.Looper.loop(Looper.java:123) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.app.ActivityThread.main(ActivityThread.java:4370) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at java.lang.reflect.Method.invokeNative(Native Method) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at java.lang.reflect.Method.invoke(Method.java:521) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:868) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at dalvik.system.NativeStart.main(Native Method) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.mipixel.rgblamp.ColorPickerView 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.view.LayoutInflater.createView(LayoutInflater.java:503) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.view.LayoutInflater.inflate(LayoutInflater.java:385) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java: 198) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.app.Activity.setContentView(Activity.java:1625) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at com.mipixel.rgblamp.RGBLamp.onCreate(RGBLamp.java:22) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: 1047) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2466) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): ... 11 more 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): Caused by: java.lang.NoSuchMethodException: ColorPickerView(Context,AttributeSet) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at java.lang.Class.getMatchingConstructor(Class.java:674) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at java.lang.Class.getConstructor(Class.java:486) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): at android.view.LayoutInflater.createView(LayoutInflater.java:475) 04-24 04:03:58.391: ERROR/AndroidRuntime(12529): ... 20 more 04-24 04:03:58.591: ERROR/SemcCheckin(12529): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump 04-24 04:03:59.011: ERROR/SemcCheckin(1748): Get Crash Level : java.io.FileNotFoundException: /data/semc-checkin/crashdump Any help is appreciated. Thank you. -- You received this message because you
Re: [android-developers] Custom view and java.lang.NoSuchMethodException for android.view.InflateException
On Sat, Apr 23, 2011 at 10:33 PM, FJ_Sanchez f...@mipixel.com wrote: I've take part of the ColorPicker code from APIDemo to make a custom View in a separate class. Just now I can create this view and set as content from code and it works. The problem comes when I want to do it from xml file. The error says that it cannot find the 2 argument's constructor for the class, but it is in the class... So I don't understand why am I getting this error... Perhaps it is not public. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in London: http://bit.ly/smand1, http://bit.ly/smand2 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom View question
Here's my problem. I finally figured out how to get my custom view working, but discovered that canvas.drawCircle(..) draws based on the screens dimensions and not the underlying bitmap (I may be misusing some terms/concepts here, still a little iffy on the whole custom view). Basically, I have a bitmap of a map image, and I want to be able to draw based on the bitmap's pixel dimensions, and to the bitmap if possible, so that when it's panned/zoomed, it stays in its respective place. Here is the code for my custom view. I x'd out my latitude and longitude. The touch handling is code adapted from a Hello, Android (3e) excerpt. package mikey.gps.NAV; import java.util.Vector; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PointF; import android.util.AttributeSet; import android.util.FloatMath; import android.view.MotionEvent; import android.view.View; public class CustomView extends View { private int mMode; private double curLat, curLng; public static final int MAP = 0; public static final int NAV = 1; private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); VectorLocationNode mPath = new VectorLocationNode(); Bitmap map; //Geographical information for translating to pixels private double XZero = xx; private double YZero = yyy; private double XWidth = 0.013884; private double YWidth = 0.006934; //Image dimensions private double IWidth = 1389; private double IHeight = 971; //Matrices for scaling the image public Matrix matrix = new Matrix(); Matrix savedMatrix = new Matrix(); static final int NONE = 0; static final int DRAG = 1; static final int ZOOM = 2; int mode = NONE; PointF start = new PointF(); PointF mid = new PointF(); float oldDist = 1f; public CustomView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CustomView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } public CustomView(Context context) { super(context); init(); } private void init() { map = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.campus); //mPaint.setFilterBitmap(true); matrix.setTranslate(1f, 1f); invalidate(); } /* When the view is invalidated, onDraw does different actions * depending on its mode. If it is the map display, it simply * draws a circle on the current location. If it is on navigate, * it draws a circle on the start and goal nodes, then lines to * form the path. * * (non-Javadoc) * @see android.view.View#onDraw(android.graphics.Canvas) */ @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); canvas.drawBitmap(map, matrix, mPaint); if(mMode == NAV) { canvas.drawCircle(translateX(mPath.lastElement().lat), translateY(mPath.lastElement().lng), 10, mPaint); canvas.drawCircle(translateX(mPath.firstElement().lat), translateY(mPath.firstElement().lng), 10, mPaint); for(int i = 0; i mPath.size()- 1; i++) { LocationNode startNode = mPath.elementAt(i); LocationNode stopNode = mPath.elementAt(i+1); float startX = translateX(startNode.lat); float startY = translateY(startNode.lng); float stopX = translateX(stopNode.lat); float stopY = translateY(stopNode.lng); canvas.drawLine(startX, startY, stopX, stopY, mPaint); } } else if (mMode == MAP) { canvas.drawCircle(translateX(curLat), translateY(curLng), 10, mPaint); } } @Override public boolean onTouchEvent(MotionEvent e) { // TODO Auto-generated method stub WrapMotionEvent event = WrapMotionEvent.wrap(e); switch (event.getAction() MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN:
Re: [android-developers] Custom View question
Hi, What underlying bitmap are you referring to? In the onDraw() method, the Canvas is used to draw onto your application's window buffer. On Mon, Feb 14, 2011 at 7:55 PM, Mikey mikeynic...@gmail.com wrote: Here's my problem. I finally figured out how to get my custom view working, but discovered that canvas.drawCircle(..) draws based on the screens dimensions and not the underlying bitmap (I may be misusing some terms/concepts here, still a little iffy on the whole custom view). Basically, I have a bitmap of a map image, and I want to be able to draw based on the bitmap's pixel dimensions, and to the bitmap if possible, so that when it's panned/zoomed, it stays in its respective place. Here is the code for my custom view. I x'd out my latitude and longitude. The touch handling is code adapted from a Hello, Android (3e) excerpt. package mikey.gps.NAV; import java.util.Vector; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PointF; import android.util.AttributeSet; import android.util.FloatMath; import android.view.MotionEvent; import android.view.View; public class CustomView extends View { private int mMode; private double curLat, curLng; public static final int MAP = 0; public static final int NAV = 1; private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); VectorLocationNode mPath = new VectorLocationNode(); Bitmap map; //Geographical information for translating to pixels private double XZero = xx; private double YZero = yyy; private double XWidth = 0.013884; private double YWidth = 0.006934; //Image dimensions private double IWidth = 1389; private double IHeight = 971; //Matrices for scaling the image public Matrix matrix = new Matrix(); Matrix savedMatrix = new Matrix(); static final int NONE = 0; static final int DRAG = 1; static final int ZOOM = 2; int mode = NONE; PointF start = new PointF(); PointF mid = new PointF(); float oldDist = 1f; public CustomView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CustomView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } public CustomView(Context context) { super(context); init(); } private void init() { map = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.campus); //mPaint.setFilterBitmap(true); matrix.setTranslate(1f, 1f); invalidate(); } /* When the view is invalidated, onDraw does different actions * depending on its mode. If it is the map display, it simply * draws a circle on the current location. If it is on navigate, * it draws a circle on the start and goal nodes, then lines to * form the path. * * (non-Javadoc) * @see android.view.View#onDraw(android.graphics.Canvas) */ @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); canvas.drawBitmap(map, matrix, mPaint); if(mMode == NAV) { canvas.drawCircle(translateX(mPath.lastElement().lat), translateY(mPath.lastElement().lng), 10, mPaint); canvas.drawCircle(translateX(mPath.firstElement().lat), translateY(mPath.firstElement().lng), 10, mPaint); for(int i = 0; i mPath.size()- 1; i++) { LocationNode startNode = mPath.elementAt(i); LocationNode stopNode = mPath.elementAt(i+1); float startX = translateX(startNode.lat); float startY = translateY(startNode.lng); float stopX = translateX(stopNode.lat); float stopY = translateY(stopNode.lng); canvas.drawLine(startX, startY, stopX, stopY, mPaint); } } else if (mMode == MAP) { canvas.drawCircle(translateX(curLat), translateY(curLng), 10, mPaint); } } @Override public boolean onTouchEvent(MotionEvent e) { // TODO Auto-generated method stub WrapMotionEvent event =
[android-developers] Custom view in an App Widget
Hello! Am I correct in assuming that I can't use a custom view (a specialisation of View) in an App Widget? This guide: http://developer.android.com/guide/topics/appwidgets/index.html seems to suggest that this is the case. :.:: mattias -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Custom view in an App Widget
On Fri, Feb 4, 2011 at 12:59 PM, Mattias Svala thebra...@gmail.com wrote: Am I correct in assuming that I can't use a custom view (a specialisation of View) in an App Widget? Correct. That is because your code cannot be running in somebody else's process, such as the home screen's process. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom View with Children Implemented onGestureListener
Hi, I have a custom View with Children and it has also implemented OnGestureListener. In custom view class I have also overridden onSingleTapUp() function as below. @Override public boolean onSingleTapUp(MotionEvent e) { // TODO Auto-generated method stub return false; } How I will Intercept this Tap action from my MAIN ACTIVITY class when I tap on any child of custom view? Thanks in advance for your explanation. Please give some example or pointer. argongold -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom View
Afternoon All, I am working on trying to streamline my app a bit and i want to get the most out of my custom view and the xml layout. So I have a custom object with 4 images and a textview in the whole view, I have created functions to inject the images I want to use in code, but I am looking to do something like the following: customView image1Property.src ='img;/ I may not be too clear and for that I apologize for now. All I want to do is populate a child view form a parent view more or less ...but in the xml and not by the setup code. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Custom View
Here is a nice example that you can refer to. http://blog.pocketjourney.com/2008/05/02/android-tutorial-42-passing-custom-variables-via-xml-resource-files/ There is also an official sample which I guess needs a bit of modification (I am not sure, don't remember) It's in the samples of the API level 8. the class is called CustomView1.java. You will have to find the related xmls from the samples folder. Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com On Wed, Nov 24, 2010 at 2:41 AM, Albert Rosa rosalb...@gmail.com wrote: Afternoon All, I am working on trying to streamline my app a bit and i want to get the most out of my custom view and the xml layout. So I have a custom object with 4 images and a textview in the whole view, I have created functions to inject the images I want to use in code, but I am looking to do something like the following: customView image1Property.src ='img;/ I may not be too clear and for that I apologize for now. All I want to do is populate a child view form a parent view more or less ...but in the xml and not by the setup code. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Custom view in gallery
On Thu, Nov 18, 2010 at 12:59 AM, Shalini coolcool.shal...@gmail.comwrote: i want a custom view which will contain one textview and one imageview ,in a gallery as an item. OK. can anyone send me the code for that? No one is going to do your work for you, sorry. Please tell me how to do this. Read the documentation and look at the samples. This is basic Android stuff. Show your work if you get stuff or need help with specifics. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] custom view in widget
Can I use a custom view like com.examples.me.customview in the xml file of a app widget and can then draw in the onDraw of the custom view? Or do I have to draw into the drawing cache of an ImageView instead? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom view in gallery
hi i want a custom view which will contain one textview and one imageview ,in a gallery as an item. can anyone send me the code for that? Please tell me how to do this. waiting 4 reply -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] custom view onDraw() in layout xml not called
On Thu, Nov 11, 2010 at 8:24 AM, pvee ppillai...@gmail.com wrote: View class=android.pvee.vm.animateview android:id=@+id/ animateview01 android:layout_gravity=top android:layout_weight=1 android:background=@drawable/vmquad android:layout_width=fill_parent android:layout_height=fill_parent/View What's this about? I don't see any class attribute in the documentation. You probably want to put your class name instead of View and get rid of the class= portion. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] custom view onDraw() in layout xml not called
You can use this syntax, but you need to use lowercase view: view class=org.my.stuff.MyView / On Fri, Nov 12, 2010 at 9:52 AM, TreKing treking...@gmail.com wrote: On Thu, Nov 11, 2010 at 8:24 AM, pvee ppillai...@gmail.com wrote: View class=android.pvee.vm.animateview android:id=@+id/ animateview01 android:layout_gravity=top android:layout_weight=1 android:background=@drawable/vmquad android:layout_width=fill_parent android:layout_height=fill_parent/View What's this about? I don't see any class attribute in the documentation. You probably want to put your class name instead of View and get rid of the class= portion. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] custom view does not display properly after closing and reloading app
I am having trouble with a custom view displaying properly. When the view is first loaded (meaning the app is not cached in memory), the view displays OK. However, when the app is closed with the back button and then reloaded, the view is a black screen and does not display as intended. The view looks something like as follows. Basically, what happens is the constructor starts a timer which only stops when the view functions getHeight() and getWidth() are non- zero. The actual values for the screen height and width are needed by the draw function. What can I do to get the following view to draw when the app is reloaded. public class CustomView extends View { private volatile boolean initializationDone = false; private Timer initializationTimer; public CustomView(Context context) { super(context); initializationDone = false; // do some other stuff here initializationTimer = new Timer(); initializationTimer.scheduleAtFixedRate(new InitializationHelper(), 50, 50); } private class InitializationHelper extends TimerTask { private volatile boolean timerCancelled = false; public void run() { if ((CustomView.this.getHeight() 0) (CustomView.this.getWidth() 0)) { if (!timerCancelled) { timerCancelled = true; if (initializationTimer != null) { initializationTimer.cancel(); initializationTimer.purge(); } // do some more initialization here initializationDone = true; } postInvalidate(); } } } @Override public void onDraw(Canvas canvas) { super.onDraw(canvas); if (!initializationDone) { return; } // draw stuff here } } I have tried replacing the timer with the following, I still do not see the view display after starting the app again just after being closed. (It does display properly when the app is loaded fresh into memory with the following). @Override protected void onSizeChanged (int w, int h, int oldw, int oldh) { if ((w = 0) || (h = 0)) return; initializationDone = true; postInvalidate(); } Any ideas? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] custom view onDraw() in layout xml not called
hi all android gurus, I recently started android programming and stuck on custom views I have seen a number of posts similar to me with some tips, suggestions etc but none worked for me heres my problem I have my main activity defined in main.xml which has got a button to display another activity which is something like LinearLayout android:id=@+id/LinearLayout01 android:layout_width=fill_parent android:layout_height=fill_parent xmlns:android=http://schemas.android.com/apk/res/android; android:orientation=vertical View class=android.pvee.vm.animateview android:id=@+id/ animateview01 android:layout_gravity=top android:layout_weight=1 android:background=@drawable/vmquad android:layout_width=fill_parent android:layout_height=fill_parent/View TableLayout android:id=@+id/TableLayout01 android:layout_height=wrap_content android:layout_width=fill_parent TableRow android:id=@+id/TableRow01 android:layout_height=wrap_content android:layout_width=fill_parent android:gravity=center_horizontal Button android:id=@+id/Button01 android:layout_width=wrap_content android:layout_height=wrap_content android:text=Home/Button ... ... /TableRow /TableLayout /LinearLayout in manifest file I declared above activity as activity android:name=.activity name / and for the button click btnStart.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ Intent animate = new Intent(v.getContext(), activity name.class); startActivityForResult(animate, 0); } I have custom view class animateview which overrides ondraw public class animateview extends View { public animateview(Context context, AttributeSet attrs) { super(context, attrs); Log.i(animateview, in constructor); } /* @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { Log.i(animateview, in on measure); super.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(getMeasuredWidth(), getMeasuredHeight()); }*/ @Override protected void onDraw(Canvas canvas) { Log.i(animateview, in draw + canvas.toString()); canvas.drawText(this is a test, 20, 10, null); } } but when this activity is called onDraw never called..or onMesure I have overridden onMeasure to set size but It didnt work... and I put log message in the constructor of this class - didnt work but when this activity is called the custom view background image is drawn by the layout which is set in above xml any tips would be greatly appreciated..I can post more details or code snippet if u want thanks in advance regards pvee -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom View as Gallery Item
Hi All, As i see in Gallery example in APIDemos,it is possible to add Image listView or textviews as Gallery items. But my requirement is,I need to add both textview and Image combined as a single item in Gallery. All examples are showing either imageview adapter or text view adapter as Gallery items. But I want to add Custom View as Gallery Item. Any way to do this? Please help. Thanks kavitha -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Custom View as Gallery Item
Sure, create a custom view, and use that, else, you can create the custom view in the getView method of the adapter. On Wed, Oct 6, 2010 at 6:21 PM, kavitha b kkavith...@gmail.com wrote: Hi All, As i see in Gallery example in APIDemos,it is possible to add Image listView or textviews as Gallery items. But my requirement is,I need to add both textview and Image combined as a single item in Gallery. All examples are showing either imageview adapter or text view adapter as Gallery items. But I want to add Custom View as Gallery Item. Any way to do this? Please help. Thanks kavitha -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Custom View as Gallery Item
yes,I tried that using inflater. But it is not working.No views are shown in gallery then. Any example with that? On Wed, Oct 6, 2010 at 6:23 PM, Kumar Bibek coomar@gmail.com wrote: Sure, create a custom view, and use that, else, you can create the custom view in the getView method of the adapter. On Wed, Oct 6, 2010 at 6:21 PM, kavitha b kkavith...@gmail.com wrote: Hi All, As i see in Gallery example in APIDemos,it is possible to add Image listView or textviews as Gallery items. But my requirement is,I need to add both textview and Image combined as a single item in Gallery. All examples are showing either imageview adapter or text view adapter as Gallery items. But I want to add Custom View as Gallery Item. Any way to do this? Please help. Thanks kavitha -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Custom View as Gallery Item
That should work. Media media = medias.get(index); if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.media_adapter, null, true); } ImageView img = (ImageView) convertView.findViewById(R.id.mediaImage); img.setImageBitmap(media.getBmp()); img.setLayoutParams(new LayoutParams(53, 53)); Something like this. I am not sure why isn't it working. Maybe, it is being diaplyed, but you have to adjust the layout a bit. On Wed, Oct 6, 2010 at 6:31 PM, kavitha b kkavith...@gmail.com wrote: yes,I tried that using inflater. But it is not working.No views are shown in gallery then. Any example with that? On Wed, Oct 6, 2010 at 6:23 PM, Kumar Bibek coomar@gmail.com wrote: Sure, create a custom view, and use that, else, you can create the custom view in the getView method of the adapter. On Wed, Oct 6, 2010 at 6:21 PM, kavitha b kkavith...@gmail.com wrote: Hi All, As i see in Gallery example in APIDemos,it is possible to add Image listView or textviews as Gallery items. But my requirement is,I need to add both textview and Image combined as a single item in Gallery. All examples are showing either imageview adapter or text view adapter as Gallery items. But I want to add Custom View as Gallery Item. Any way to do this? Please help. Thanks kavitha -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom View orientation change
I have a custom view A which extends RelativeLayout and internally uses 3 instances of custom view B: B1, B2 and B3, which can be 'flung' left or right to move to B4, B5 and B6. I want to resize the whole view based on the orientation. I have hardcoded the size of B based on the screen width of 320 (if the view is initialized in potrait mode), or 480 (landscape mode), and then use the screen density from getDisplayMetrics() to convert them into real pixel values to draw my view. Is this is best way to do it? I was trying to use onSizeChanged to look for orientation changes, but this does not work because onMeasure() is called before onSizeChanged() and the orientation change does not show up. Any advice anyone? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom View
Hi all, I want to create a custom view.In which i want to have a background image,2 buttons,1 textview. Can anybody tell me how to start with. Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Custom View
why you just dont create a xml file which has those properties ? :) -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom View changing size
How can I reset the size of a View after its onMeasure() is called and the container has been drawn? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom View in a XML Layout
I am trying to create a Custom View and display it using a layout definition in XML. However whenever the Activity that contains this Custom View is executed, the application stops and I get Forced close error. Here is the CustomView class public class CustomView extends View { private Paint paint; public CustomView(Context _context) { super(_context); paint = new Paint(); // set's the paint's colour paint.setColor(Color.GREEN); // set's paint's text size paint.setTextSize(25); // smooth's out the edges of what is being drawn paint.setAntiAlias(true); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawText(Hello World, 5, 30, paint); // if the view is visible onDraw will be called at some point // in the future invalidate(); } } and the entry in main.xml com.jc.test.CustomView android:id=@+id/customview/ / TextView android:id=@+id/entry android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/hello / Any help or suggestions?? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom view, instantiated in XML, overridden onDraw, canvas size outside allocated space.
Hi, I've got a custom class being loaded up by my layout XML, and drawing to the screen. This much works perfectly. First some background: In my main layout XML I define a tabhost, linearlayout, framelayout and tabwidget. Following on from this, each activity has its own layout XML that defines how its UI is laid out inside the parent framelayout when the activities are launched by selecting a tab. The problem comes when I try to draw a line at the bottom of the canvas in the overridden onDraw(Canvas) function in my custom view (class CompassView extends View); it is drawn underneath the tabwidget defined in the main parent XML! I fetch the size of the canvas with canvas.getHeight(). The value it returns seems to include the space underneath the tabwidget, but not the space occupied by the notification bar at the top. Note that my tabwidget is at the bottom of the screen. Here is the layout for the child view which sits inside the framelayout of the parent XML: ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:id=@+id/compass android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent com.tjhowse.geoloc.CompassView android:layout_width=fill_parent android:layout_height=fill_parent/ /LinearLayout At the start of the constructor for my custom view: public CompassView(Context context, AttributeSet attrs) { super(context, attrs); setLayoutParams(new LayoutParams(context, attrs)); ... I would've thought the fill_parent attribute would've prevented the view, and thus the canvas, from overlapping with the tabwidget. If I replace my custom class with: Button android:id=@+id/pbTest android:layout_width=wrap_content android:layout_height=fill_parent android:text=BUTAN OMG / ...the button correctly fills the available space, and has a proper bottom edge that clearly finishes before it intersects the tabwidget. Any thoughts? Thanks, tjhowse. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Custom view disappears, when scrolling
Hi. I wrote a custom view for ListView rows. It works fine, but when I scroll it, all views in the list disappears. This this how I draw my view: @Override protected void onDraw(Canvas canvas) { //poster if(poster != null) canvas.drawBitmap(poster, padding, padding, paint); //title canvas.drawText(title, 55 + padding, 16 + padding, paint); } Any suggestions, how to fix this? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: [android-developers] Custom view disappears, when scrolling
did u set cachecolorhint to #0 when u scroll if a black screen will appear, if u don't set as above. My guess is drawn and its masked by the black background of listview when it scrolls. can u put some logs to see if ur method is actually called . On Fri, Mar 19, 2010 at 4:47 AM, sunabozu tro...@gmail.com wrote: Hi. I wrote a custom view for ListView rows. It works fine, but when I scroll it, all views in the list disappears. This this how I draw my view: @Override protected void onDraw(Canvas canvas) { //poster if(poster != null) canvas.drawBitmap(poster, padding, padding, paint); //title canvas.drawText(title, 55 + padding, 16 + padding, paint); } Any suggestions, how to fix this? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe from this group, send email to android-developers+ unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[android-developers] Custom View - obtain android:layout_width value
I have a custom View, it is created from xml - how can I obtain the android:layout:width value in the constructor View(Context x, AttributeSet a) ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Custom View donot Draw in ListView
Hello, I have a query, When I try to use a customview in the listview, the custom view donot display. All other views are displayed except the custom view. When I try to display the view like a normal layout (not in a list), it displays fine. Can anyone please help me to draw the customview in the list? the main.xml file - layout that contains the custom view ?xml version=1.0 encoding=utf-8? LinearLayout TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/hello / CheckBox android:id=@+id/check2 android:layout_width=wrap_content android:layout_height=wrap_content android:text=checkbox_2 / app.customise.tab.CustomBackground android:id=@android:id/list android:layout_width=wrap_content android:layout_height=wrap_content/ /LinearLayout the list.xml file - the list view file LinearLayout FrameLayout ListView android:id=@android:id/android:list android:layout_width=fill_parent android:layout_height=fill_parent/ /FrameLayout /LinearLayout the CustomBackground.java - class that extends the View class and draws a rounded rectangle public class CustomBackground extends View{ public CustomBackground(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub mRect = new Rect(40, 0, 310, 90); mDrawable = new GradientDrawable (GradientDrawable.Orientation.TOP_BOTTOM, new int[] { 0xFFA5C3E9, 0xFF548DD4 }); mDrawable.setShape(GradientDrawable.RECTANGLE); mDrawable.setGradientRadius((float)(Math.sqrt(2) * 60)); } private RectmRect; private GradientDrawable mDrawable; public CustomBackground(Context context) { super(context); // TODO Auto-generated constructor stub mRect = new Rect(40, 0, 310, 90); mDrawable = new GradientDrawable (GradientDrawable.Orientation.TOP_BOTTOM, new int[] { 0xFFA5C3E9, 0xFF548DD4 }); mDrawable.setShape(GradientDrawable.RECTANGLE); mDrawable.setGradientRadius((float)(Math.sqrt(2) * 60)); } void setCornerRadii(GradientDrawable drawable, float r0, float r1, float r2, float r3) { drawable.setCornerRadii(new float[] { r0, r0, r1, r1, r2, r2, r3, r3 }); } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub //super.onDraw(canvas); System.out.println(ON DRAW CALLED); mDrawable.setBounds(mRect); float r = 10; canvas.translate(10, 10); mDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); setCornerRadii(mDrawable, r, r, r, r); mDrawable.draw(canvas); invalidate(); } the DummyActivity.class extends ListActivity public class DummyActivity extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /** * Display layout of main.xml with custom view. * Works fine. Displays one checkbox, two radio buttons and one rounded rectangle * Class extends Activity */ // setContentView(R.layout.main); /** * The above display in list. * Displays one checkbox, two radio buttons. Rounded rectangle not displayed */ setContentView(R.layout.list); mAdapter ma = new mAdapter(this); for(int i=0;i5;i++) { ma.add(i); } this.setListAdapter(ma); } public class mAdapter extends BaseAdapter { private Context ctx; ListIntegercount = new ArrayListInteger(); public mAdapter(Context c) { ctx=c; } public void add(int i) { count.add(i); } @Override public int getCount() { // TODO Auto-generated method stub return count.size(); } @Override public Object getItem(int position) { // TODO Auto-generated method stub return count.get(position); } @Override public long getItemId(int position) { // TODO Auto-generated method stub return 0; } @Override public View getView(int
[android-developers] Custom View using XML layout EditTexts: SavedState conflict
I'm trying to figure out how to properly make a custom view consisting of a LinearLayout and some children, one of which is a EditText. To make this simple, I've pared down the code to the simplest possible case. res/layout/bughunt.xml is a basic definition of a custom view; it's just a layout with a single EditText inside. ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:orientation=horizontal android:gravity=center_vertical android:layout_width=wrap_content android:layout_height=wrap_content EditText android:id=@+id/text1 android:layout_width=wrap_content android:layout_height=40sp android:gravity=center android:width=50sp android:singleLine=true/ /LinearLayout My custom view class: public class BugHunt extends LinearLayout { public BugHunt(Context context) { super(context); initLayout(context); } public BugHunt(Context context, AttributeSet attrs) { super(context, attrs); initLayout(context); } private void initLayout(Context context) { LayoutInflater i = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); i.inflate(R.layout.bughunt, this); } } Then I put two instances like the following in an Activity layout file: my.package.BugHunt layout_width=wrap_content layout_height=wrap_content / The problem I'm having is when the EditTexts save state, they overwrite each other's state. To reproduce this, put two or more instances of BugHunt into an Activity, run it, and enter some (different) text into each EditText. Then, switch the screen orientation. After the layout is redrawn, all EditTexts will have the same text in them (the text from whichever EditText saved state last). I can only guess that I'm not using the LayoutInflater properly. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Custom view asking login details
Hi, i m new to android. I am trying to create custom component. developer wil use this component just like any other component like textview or editText in his layout.xml file. I want this component to be created and rendered by java file only. No layout xml is used. i am not sure whether to extend my class to View or ViewGroup or some layout and then add say textview and/or edittext. i tried by extending to View class but faced many problems in adding simple textVIew to it. I am pasting following code. Problem with it is. I can see red square (which i think is a viewgroup) on emulator but not able to see textView added to it. Please help me. i have expressed my intentions above, to create forms or a form like reusable component. //My form impletation java file public class Form extends ViewGroup { AttributeSet attrSet; LinearLayout.LayoutParams layParams; Context moContext; public Form(Context context) { super(context); this.moContext = context; initForm(); } public Form(Context context, AttributeSet attributeSet) { super(context,attributeSet); this.attrSet = attributeSet; this.moContext = context; initForm(); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); setVisibility(VISIBLE); initForm(); } public void initForm() { setVisibility(VISIBLE); layParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); layParams.gravity = LinearLayout.HORIZONTAL; layParams.setMargins(5, 5, 5, 5); setLayoutParams(layParams); setBackgroundColor(Color.RED); TextView textView = new TextView(getContext(), attrSet); textView.setText(A); textView.setBackgroundColor(Color.YELLOW); textView.bringToFront(); invalidate(); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { } } //layout.xml which will be used by some activity ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent com.android.custom.Form android:id=@+id/mform android:layout_width=fill_parent android:layout_height=wrap_content / /LinearLayout Please guide me through. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] custom view like login form
Hi, i m new to android. I am trying to create custom component. developer wil use this component just like any other component like textview or editText in his layout.xml file. I want this component to be created and rendered by java file only. No layout xml is used. i am not sure whether to extend my class to View or ViewGroup or some layout and then add say textview and/or edittext. i tried by extending to View class but faced many problems in adding simple textVIew to it. I am pasting following code. Problem with it is. I can see red square (which i think is a viewgroup) on emulator but not able to see textView added to it. Please help me. i have expressed my intentions above, to create forms or a form like reusable component. //My form impletation java file public class Form extends ViewGroup { AttributeSet attrSet; LinearLayout.LayoutParams layParams; Context moContext; public Form(Context context) { super(context); this.moContext = context; initForm(); } public Form(Context context, AttributeSet attributeSet) { super(context,attributeSet); this.attrSet = attributeSet; this.moContext = context; initForm(); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); setVisibility(VISIBLE); initForm(); } public void initForm() { setVisibility(VISIBLE); layParams = new LinearLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); layParams.gravity = LinearLayout.HORIZONTAL; layParams.setMargins(5, 5, 5, 5); setLayoutParams(layParams); setBackgroundColor(Color.RED); TextView textView = new TextView(getContext(), attrSet); textView.setText(A); textView.setBackgroundColor(Color.YELLOW); textView.bringToFront(); invalidate(); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { } } //layout.xml which will be used by some activity ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent com.android.custom.Form android:id=@+id/mform android:layout_width=fill_parent android:layout_height=wrap_content / /LinearLayout Please guide me through. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Custom view or?
Hi. I need to develop some widget like a standard Gallery. On visible part of the screen should be three images. Images may be scrolled up and down or left and right in dependence on orientation. Image in focus should be larger then others. Scrolling should be realized by touching on left or right image or tilting of device. What is the best way of this solution? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] custom View using Adapter iface
hi, i want to create custom View showing possibly several items. i think using Adapter interface would be good idea. my question is: should i extend AdapterView? if so, what is the most imortant when doing this (e.g. AdapterView is ViewGroup, so how should i manage children)? thanks, pskink --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] custom View using Adapter iface
hi, i want to create custom View showing possibly several items. i think using Adapter interface would be good idea. my question is: should i extend AdapterView? if so, what is the most imortant when doing this (e.g. AdapterView is ViewGroup, so how should i manage children)? thanks, pskink --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Custom view - canvas height incorrect?
To simply debugging of my custom View, I'm trying to draw a border around it so I can see its exact size/position. The left and right sides of the border draw correctly, but the top and bottom end up outside the screen by about 50 pixels. My guess is that canvas.getHeight() isn't accounting for the notification bar at the top. What am I doing wrong? Here's my code: protected void onDraw(Canvas canvas) { super.onDraw(canvas); Log.w(, canvas bounds: + canvas.getClipBounds() + , width/ height: + canvas.getWidth() + , + canvas.getHeight()); //draw border canvas.drawLine(0, 0, canvas.getWidth(), 0, mBorderPaint); canvas.drawLine(canvas.getWidth(), 0, canvas.getWidth(), canvas.getHeight(), mBorderPaint); canvas.drawLine(canvas.getWidth(), canvas.getHeight(), 0, canvas.getHeight(), mBorderPaint); canvas.drawLine(0, 0, 0, canvas.getHeight(), mBorderPaint); } Here's the output of the log statement: 10-24 02:01:35.488: WARN/(1300): onDraw called: canvas bounds:Rect(0, 0, 320, 430), width/height: 320, 480 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Custom view scrolling
I am trying to implement a custom view which can scroll horizontally and vertically. I have called setHorizontalScrollBarEnabled(true); setVerticalScrollBarEnabled(true); but no scroll bars are displayed. I have overridden computeHorizontalScrollExtent etc. but none of these methods are called. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---