android-custom-view

Custom view and member variables in Android

天涯浪子 提交于 2019-12-12 01:35:20
问题 I'm trying to create a animated custom view in Android but I'm having trouble with the view objects member variables. After i run invalidate() the variables get reinitialized. I got this in my custom view called Thermometer private float handTarget = 40; public void setHandTarget(float temperature) { Log.e(TAG, "setHandTarget!"); handTarget = temperature; Log.e(TAG, "handTarget="+handTarget); handInitialized = true; invalidate(); } @Override protected void onDraw(Canvas canvas) { Log.e(TAG,

Add Prefrences Screen to an Activity with a customized window title

自古美人都是妖i 提交于 2019-12-12 01:03:50
问题 I know its possible to add a button to a prefernces Screeen activtiy. I read this question How to add a button to PreferenceScreen and it works perfect. But if I want to add my custom title my application just crashes. The customtitle works perfect in its own activity and the preference screen with button works also perfect in its own activity. So my problem is only based on bringing these two functions together. heres my code in of the java file public class TestHeadlineActivity extends

onClicks in a custom view are not responding:

笑着哭i 提交于 2019-12-12 00:47:53
问题 I have created a custom view in which I want to implement some onClick actions. I created the following: Custom View XML Layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/leftMenu" android:layout_width="100dp" android:layout_height="fill_parent" android:background="@drawable/left_menu_background" android:orientation="vertical" > <ImageButton android:id="@+id/left_menu_close_button" android:layout_width=

Drawing multiple custom views

假如想象 提交于 2019-12-11 21:39:38
问题 I'm trying to draw multiple custom views in a layout but only the first view I add it's drawn. My custom view class is: public ButtonView(Context context, int k) { super(context); this.setX(20+k*80); init(); } private void init(){ paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(0x99ffffff); } @Override protected void onDraw(Canvas cv){ cv.drawText(""+getX(), 0, 80, paint); } I'm displaying the text of the x coordinate in order to know which view is drawn. This is the code of onCreate

How to change Custom Listview row color change alternatively?

喜夏-厌秋 提交于 2019-12-11 19:06:05
问题 I have created custom LISTVIEW for showing searched result list want to show each row with background color I tried out with some code but not working as per my requirement please help me out here is my code public class ListCustomBaseAdapter extends BaseAdapter { private static ArrayList<SearchResult> searchArrayList; private LayoutInflater mInflater; public ListCustomBaseAdapter(Context context, ArrayList<SearchResult> results) { searchArrayList = results; mInflater = LayoutInflater.from

How can I have a calendar with date as horizontal rows and time in vertical columns

a 夏天 提交于 2019-12-11 17:23:17
问题 the title says it all. I've looked into android arsenal but couldn't find anything that fit my needs. I need to have all the functionality of calendar. Person1 and Person2 can be any string. the only problem is the horizontal dates with vertical columns time. How do I do that? any links can get me started would be fine. Thanks. 回答1: multiple recyclerView will help you to achieve this ... date-picker in one and time-picker in another align them in horizontal and vertical as needed. 来源: https:/

How to transform a videoview into a circular shape?

非 Y 不嫁゛ 提交于 2019-12-11 16:38:49
问题 I want to play a video in full screen in a videoview and after some time I want to crop to a circular view ? How can I achieve that ? 回答1: Another way is put this type of image overlay on your videoview Relative or FrameLayout (Circuler is transprent so videoview will visible only in circle) By default make visibility GONE this imageView and Change VISIBLE it runtime when you want. MAY BE HELPFUL TO YOU 回答2: There is a better way. You can create a custom SurfaceView. Which actually clips the

Android custom view attributes - 'color' as attribute name disallowed

喜你入骨 提交于 2019-12-11 13:52:45
问题 I've made a simple custom view, a "ColorSwatch". It's circular, shows the assigned color and if that color has transparency, the color is drawn atop a checker pattern. The view works fine. My problem is that when I define the custom attributes for the swatch (in values/attrs_color_swatch_view.xml ), I can't specify an attribute named "color". The compiler complains that color is already defined, and points me to my colors.xml file. As a workaround, I called the parameter swatchColor , but I'd

Android: Undo redo in CustomView

痴心易碎 提交于 2019-12-11 13:45:40
问题 I'm trying to implement undo-redo functionality for erasing image in the custom view and have tried to implement the solution from ANDROID - Undo and Redo in canvas but when i click undo all it does is fill the coordinates and the circle with the same paint object that is underneath the bitmap and not the bitmap itself as the undo should function.Please help. public CustomView(Context context, AttributeSet attrs) { super(context, attrs); xn=context; Log.e(TAG, "The Bitmap is " + bmrot);

Can you add a CustomVIew to a ListView without any ArrayAdapters?

ⅰ亾dé卋堺 提交于 2019-12-11 12:17:54
问题 Is there a way to add a custom view with an edittext and a button without any adapters because I dont have any arrays I just need a custom view in each listview . Something like listitem.add(custom view) and i can tell how many times in a for loop. And where do i programme the button in the custom view? 来源: https://stackoverflow.com/questions/37228690/can-you-add-a-customview-to-a-listview-without-any-arrayadapters