Menu
  • HOME
  • TAGS

How to Apply CSS Style Code into My Custom TextView in Android

android,css,textview,stylesheet,android-custom-view

You can use Something like this might help you. textview.setText(Html.fromHtml("<p font-color="blue">database content will be here in HTML format</p>")); ...

Customize a ProgressBar to become a Thermometer

android,drawing,draw,android-custom-view,android-progressbar

First I would provide 2 setters, one for color and one for the temperature value, normalized from 0 ... 1, where 0 means no visible bar, and 1 means a fully visible bar. public void setColor(int color) { mColor = color; invalidate(); // important, this triggers onDraw } public void...

No padding-effect in custom ImageView

android,image,imageview,padding,android-custom-view

When you are setting paddings to view, they should be considered during the drawing. You can achieve this, by creating a BitmapDrawable variable in your custom view, and then initialize it and draw according to padding, for example. private BitmapDrawable mDrawable; public void setBitmap(Bitmap bitmap) { mDrawable = new BitmapDrawable(getResources(),...

Custom editText on android

android,android-layout,android-edittext,frontend,android-custom-view

If you want the blue line on the left, you can just set the background on the EditText, such as, <EditText android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:background="@drawable/custom_edittext" android:layout_weight="1" /> Then create another file in your drawable folder this is called custom_layer.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:bottom="-5dp" android:right="-5dp"...

saving drawing to sdcard from a custom view android

android,bitmap,drawing,android-canvas,android-custom-view

On the assumption you want to save the file to the devices storage, here is the solution i use... Add permission to manifest: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> Here is how I am doing it: // Variables i needed private String mFileName; private Bitmap mBitmap; // apply this listener to your button private...

onTouchEvent is not getting executed

android,android-custom-view,ontouchlistener

Try to override instead of onTouch method the following method. @Override public boolean onTouchEvent(MotionEvent event){....} If the touch event still doesn't gets called call somewhere in your constructor setClickable(True); ...

Nutiteq ViewLabel doesn't appear

label,polygon,android-custom-view,nutiteq

Probably the issue is that you do not measure your layout, see https://github.com/nutiteq/hellomap3d/wiki/Use-View-for-Label. You should add before webView.layout() webView.measure(400, 300); ...

Use a progressbar inside a custom view?

android,progress-bar,draw,android-custom-view

You may want to consider extending ViewGroup in your Gamecontroller_View instead of View. From the documentation: A ViewGroup is a special view that can contain other views (called children.) The view group is the base class for layouts and views containers. ...

Child class of EditText looks different than normal EditText on Android 4

android,android-layout,android-edittext,android-custom-view

Why is this happening Because you are using AppCompat. Quoting the blog post on the subject: Q: Why is my EditText (or other widget listed above) not being tinted correctly on my pre-Lollipop device? A: The widget tinting in AppCompat works by intercepting any layout inflation and inserting a...

Custom alert dialog android

android,custom-controls,android-custom-view,android-alertdialog,customdialog

I have some solution. Please look at the example below. In style xml use this: <resources> .... <style name="DialogAnimation"> <item name="android:windowEnterAnimation">@anim/abc_slide_in_bottom</item> <item name="android:windowExitAnimation">@anim/abc_slide_out_bottom</item> </style> <style name="DialogSlideAnim"> <item name="android:windowAnimationStyle">@style/DialogAnimation</item> <item...

Error with custom text-view attribute

android,android-xml,android-custom-view,android-custom-attributes

If you only get the error in the xml graphics view, add this to youre code if(!isInEditMode()) //use fonts The editor will display only default fonts....

How can i add multiple values into one column in sql?

java,android,sqlite,listview,android-custom-view

First of all, for SQLite, you need to create a table for your users, then you need 1 coulmn by element you want to put (1 for surname, 1 for name,...) except if you put in there something like a JSONObject containing your user. For example: This class is a...

how to save check box values of custom list view using shared preferences

android,listview,checkbox,sharedpreferences,android-custom-view

you can add all the checked app names in a set and then save this set in sharedprefrences:- Set<String> set =new HashSet<String>(); ch .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean b) { if() { set.add(ch.getText()); } else { set.remove(ch.getText()); } }); then in your sharedprefrences put the set...

Putting custom View into ScrollView (Or HorizontalScrollView) programmatically (No Scrolling)

android,scrollview,android-custom-view

The error was inside my customView. I didn't set the Width and Height of my view (setWidth(), setHeight()). So the view did not know how big it really is. :-( Sorry for wasting your time!...

view.invalidate invokes redraw of other view

android,android-custom-view

The better way is to change visibility of views instead of remove and add to container. It will work faster and view with visibility gone will not redraw on invalidate.

Drawing a square layout inside a circle

android,android-layout,android-custom-view

Here's how I got the solution. First I created a square frame to hold all the layouts. public class SquareFrame extends FrameLayout { public SquareFrame(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int originalWidth = MeasureSpec.getSize(widthMeasureSpec); int originalHeight = MeasureSpec.getSize(heightMeasureSpec); int required...

How to Implement Multiple List view one below the other without dividing the ActivityScreen in android

android,listview,android-listview,android-custom-view

As per earlier comment, you have several options: Like @snachmsm suggested, use multiple view types in your adapter. Or wrap multiple adapters into one using MergeAdapter. Or refer to the more recently introduced RecyclerView. If you already have three ListViews and adapters set up, the quickest solution is to go...

No resource identifier found for attribute ' ' in package 'com.app…'

android,android-studio,android-view,android-custom-view

I just changed xmlns:app="http://schemas.android.com/apk/res-auto" to xmlns:app="http://schemas.android.com/apk/lib/com.app.chasebank" and it stopped generating the errors , com.app.chasebank is the name of the package. It should work according to this Stack Overflow : No resource identifier found for attribute 'adSize' in package 'com.google.example' main.xml...

Pass Attributes before CustomView inflation in Fragment based on holder Activity

android,android-fragments,android-activity,android-custom-view

onInflated in fragment lifecycle which is called before onAttach() can solve this issue.

getSupportActionBar().setCustomView(view, layout); does not cover entire actionbar

android-layout,android-custom-view,appcompat,android-actionbar-compat

fixed it by doing: //to set same background color on entire actiobar getSupportActionBar().setBackgroundDrawable( getResources().getDrawable(R.drawable.actionbar_color)); //to display custom layout with same BG color android.support.v7.app.ActionBar.LayoutParams layout = new android.support.v7.app.ActionBar.LayoutParams(android.support.v7.app.ActionBar.LayoutParams.FILL_PARENT, android.support.v7.app.ActionBar.LayoutParams.FILL_PARENT); getSupportActionBar().setCustomView(view, layout);...

Converting Camera Coordinates to Custom View Coordinates

android,android-camera,android-canvas,android-custom-view,coordinate-systems

The Camera.Face class returns the face bound coordinates using the image frame that the phone would save into its internal storage, rather than using the image displayed in the Camera Preview. In my case, the images were saved in a different manner from the camera, resulting in a incorrect mapping....

GridLayout designing custom grids

android,design,android-custom-view,grid-layout

Depending on what you're doing, you could simply get 4 RelativeLayouts in. For example : <GridLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal"> <RelativeLayout android:layout_width="188dp" android:layout_height="186dp" android:layout_row="0" android:layout_column="0"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Large Text"...

How to use custom view inside recyclerview item?

android,android-custom-view,android-recyclerview

Finally, resolved it by using different Custom ProgressBar view DonutProgress instead of ProgressWHeel. This seems like there is something wrong in ProgressWheel but couldn't find the exact cause for it....

Android: How to get an attribute from a super class of a custom view

android,inheritance,android-custom-view

Apparently this is the right way to do it: protected void init(Context context, AttributeSet attrs, int defStyle) { super.init(context, attrs, defStyle); TypedArray b = context.obtainStyledAttributes(attrs, R.styleable.B, defStyle, 0); int subTextId = getSubTextId(b); b.recycle(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.A, defStyle, 0); int mainTextId = getMainTextId(a); a.recycle(); if (subTextId != UNDEFINED) {...

How do you pass the gravity attribute via xml for a custom view?

android,android-xml,android-custom-view

by writing: <attr format="integer" name="android:gravity"/> you are intruducing the new attribute android:gravity with integer format, of course android:gravity is already defined in the system, so you need to change it into: <attr name="android:gravity"/> ...

How to set a custom view in actionbar in android?

android,view,android-actionbar,android-custom-view

Try this If you are using support library ActionBar actionBar = getActionBar(); otherwise ActionBar actionBar = getSupportActionBar(); and then LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(R.layout.custom_actionbar, null); actionBar.setCustomView(v); Your onCreate should look like this public class MainActivity extends ActionBarActivity { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override protected void onCreate(Bundle savedInstanceState) {...

org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag item

android,xml-parsing,android-custom-view

You will be able to create a circle using this below code. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:innerRadiusRatio="2.5" android:thickness="3dp" android:useLevel="false"> <solid android:color="#B7B7B7" /> </shape> ...

No resource found that matches the given name '@style/Widget.RatingBar.Small'

android,android-custom-view

You need to create custom style for custom rating bar. you try with this in you style. <resources> <style name="AppTheme" parent="android:Theme.Light" /> <style name="foodRatingBar" parent="@android:style/Widget.RatingBar"> <item name="android:progressDrawable">@drawable/star_rating_bar_full</item> <item name="android:minHeight">48dip</item> <item name="android:maxHeight">48dip</item> </style> </resources> and your xml layout will be like this. <RatingBar...

Make my own custom component in Android

android,android-custom-view,custom-component

Based on your screenshots, it seems that you are trying to achieve a custom seekBar, not a completely new component. Based on the answer here, you can customize the seekBar with your own images instead of creating a new component.

How to create hexagonal view menu in android

android,android-layout,android-imageview,android-custom-view,android-custom-attributes

i have tried to create the layout that u required, using ImageViews, LinearLayout and applying the negative margin. I am not sure if it is the ideal way to use, but i guess you can give it try if don't want go for canvas. Please go through the below example......

Android Autocomplete onclicklistener

android,autocomplete,onclick,android-custom-view

So I found the solution. I looked into the AutoCompleteTextView class to see which methods he had and found the dismissDropDown() method. Next I passed my CustomAutoCompleteTextView to the adapter and changed the onClickListener to: view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { selectedCustomer = (Customer) view.getTag(); zoekenFragment.startSearch(selectedCustomer); customerAutocomplete.setText(selectedCustomer.getName());...

Switching to Gradle: why do I have to keep custom views from being obfuscated?

android,proguard,android-custom-view,android-gradle,dexguard

Most likely Ant was using a different configuration file, Also with Gradle you need to explicitly state you want to also use the Android proguard config file i.e. use multiple rules files like so: proguardFile getDefaultProguardFile('proguard-android.txt') proguardFile 'your/sepcific/folder/proguard.cfg' (I remember Ant never used a SDK proguard file and it used...

Custom Button wouldn't resize as expected android

android,android-custom-view

Well I guess you need to take a look to a view life cycle in android, here is a link, and here is your solution: you need to override onSizeChanged(int,int,int,int) and call your method. @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh);...

CustomEditText AppCombat tinting

android,android-custom-view,appcompat,android-styles

Widget tinting is not fully supported for some scenarios, yours included: Q: Why is my EditText (or other widget listed above) not being tinted correctly on my pre-Lollipop device? A: The widget tinting in appcompat works by intercepting any layout inflation and inserting a special tint-aware version of the widget...

Reverting a custom view

java,android,android-custom-view

Use an interface to communicate back to the Activity, just as you would for a click listener. For example, in your MainView class: // Keep a reference to a listener that should be notified of events private GameEventListener mListener; // An interface defining events that a listener will receive public...

how to create a view like MeetUp interesting tags view

android,gridview,android-custom-view,meetup

In the Meetup app, we have a custom subclass of TextView which is heavily based on the RecipientEditTextView from the AOSP frameworks/ex/chips.

bigContentView cannot be resolved or is not a field?

android,android-notifications,android-custom-view

Use this instead: Notification note = OnGoingProgress.build(); note.bigContentView = remoteView; NotificationManager.notify(... note); Reason: the big content view is a field of the notification class, not the builder class....

Get the Click event on setOnTouchListener

android,android-layout,android-listview,android-custom-view,android-scrollview

I found a solution for my own question. Instead of overriding setOnTouchListener of the ListView I have made a custom ListView and Overridden the onInterceptTouchEvent event inside the custom ListView. Please see the code below : public class CustomListView extends ListView { public CustomListView(Context context, List<DetailSummaryMonth> detailSummaryMonths) { super(context); init(context);...

Android: View onDraw never called

android,android-custom-view,ondraw

Try this code working for me. public class MainActivity extends ActionBarActivity { private RelativeLayout rl; private GridLayout glActionMenu; private int width; private MyCustomView customView; private int fromX; private int fromY; private int toX; private int toY; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // MyCustomView customView = new MyCustomView(this, 0,...

Custom View Fatal Exception

android,android-layout,android-view,android-custom-view

The problem is in the xml when you are inflating your custom view. android:background="@drawable/bottom_unbaked" The issue is the image bottom_unbaked is too large to be loaded for Android. When loading images you should make sure they are sized appropriately for the applications need. My guess is that image is way...

Custom View not showing: no height, but still width

java,android,android-layout,android-custom-view,custom-view

Ok, I figured out a workaround: When I use a LinearLayout instead of a RelativeLayout I get the result I want. It seems that the problem lies in the RelativeLayout. If someone knows why this is, or how I could still use a RelativeLayout I would be very interested. This...

Extending view group gives childcount 0?

android,android-custom-view

In state of constructing your FrameLayout, children are still not fully attached to the view. So, calling getChildCount() will return you 0. If you want to iterate over child views and update them, do it inside onLayout() or onMeasure(). Refs: http://blog.denevell.org/android-custom-views-onlayout-onmeasure.html ViewGroup - check this example code. ...

Android - How to layout and use a custom View?

android,android-layout,android-studio,android-custom-view,android-inflate

I think you're missing the most important part. You're not tying your layout to your ActionView object... Add: LayoutInflater.from(context).inflate(R.layout.<xml_of_action_view>, this, true); inside your ActionView constructor. ...

CustomView android for more objects

java,android,object,view,android-custom-view

I would not create that with x,y coordinates because of all these different screen sizes, I would use percents of screen to be sure that it looks the same on all screens (or at least, not totally different). Then, you just have to extend the View class and it should...

What's the earliest point in time I can access xml-defined subviews in a custom view

android,android-view,android-custom-view,android-inflate

I should read the docs more carefully... View.onFinishInflate() is what I was looking for....

Custom view not working in Android Lollipop

android,android-layout,android-custom-view

You need to add a constructor which looks like this: public ViewClip(Context context, AttributeSet attrs) This is clear from the stack trace: Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet] says that the <init> (constructor) with Context and AttributeSet parameter types is missing....

How to set a Background of a CustomView behind the Canvas?

android,canvas,background,android-custom-view

The solution was really easy. The background setting by XML definition 'android_background' is drawn in the draw(...) – not in the onDraw(...) – method. So, all what I had to do was to draw my shadow in the draw(...) method and then call the super.draw(...) method for drawing the background...

Android custom UI code fails to draw when SDK is changed

android,sdk,android-custom-view

Another bug occurred when I tried to run my app on Lollipop where the drawTextOnPath() call wasn't working (whereas it worked fine on KitKat). I found the issue and workaround here: Canvas.drawTextOnPath(...) not working on Lollipop. This solution also works for this drawPath() problem.

Circular View with Button Press Effect

android,android-layout,android-view,android-custom-view

I think tihs is your answer. You can download here. https://code.google.com/p/radial-menu-widget/...

Android color code WHITE conversion to hexadecimal

android,android-canvas,paint,android-custom-view,android-ui

Since color is actually an integer, you can easily convert it to hexadecimal with String.format. It seems you want to ignore the alpha channel so you can filter it out: String.format("#%06X", color & 0xffffff); ...

I created a custom view by subclassing SearchView. How can I reference in it XML now?

android,xml,android-view,android-custom-view

Fully Qualified Package Name and the xmlns:app="http://schemas.android.com/apk/res-auto" namespace did the trick. I must have had a typo somewhere.

Custom scrollview doesn't scroll

java,android,scrollview,android-custom-view

I believe @Override public boolean onTouchEvent(MotionEvent ev) { if (isEnableScrolling()) { return super.onInterceptTouchEvent(ev); } else { return false; } } should be: @Override public boolean onTouchEvent(MotionEvent ev) { if (isEnableScrolling()) { return onTouchEvent(ev); } else { return false; } } ...

Find height of parent view

android,imageview,android-custom-view

Try this way public class MyImageView extends ImageView { int parentHeight; int parentWidth; public MyImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public MyImageView(Context context, AttributeSet attrs) { super(context, attrs); } public MyImageView(Context context) { super(context); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if(((View)this.getParent()).getMeasuredWidth()!=0){ parentHeight...

Diamond Shaped Button with transparent borders

android,view,android-custom-view

You have to draw the path twice, first to draw the fill and then to draw the stroke. //initialize the paint object before onDraw method is called mBorderPaint = new Paint(); @Override protected void onDraw(Canvas canvas) { mPath.moveTo(mWidth/2 , 0); mPath.lineTo(mWidth , mHeight/2); mPath.lineTo(mWidth /2 , mHeight); mPath.lineTo(0 , mHeight/2);...

Display array of numbers with multicolor

android,dialog,android-custom-view

Spannable allows you to add add such attributes.Here is small example have look at this. TextView TV = (TextView)findViewById(R.id.mytextview01); Spannable word = new SpannableString(" 1"); word.setSpan(new ForegroundColorSpan(Color.BLUE), 0, word.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); TV.setText(word); Spannable wordTwo = new SpannableString(" 2"); wordTwo.setSpan(new ForegroundColorSpan(Color.RED), 0, wordTwo.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); TV.append(wordTwo); OR : You can also set the...

Android “elevation” is not showing a shadow under a CustomView

android,android-custom-view,android-elevation

As mentioned in Defining Shadows and Clipping Views You should implement ViewOutlineProvider abstract class by which a View builds its Outline, used for shadow casting and clipping Rectangular CustomView public class CustomView extends View { // .. @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { ///...

Create Android subviews like iOS subviews

android,ios,android-custom-view,android-viewgroup

OK, I think I got it, not sure if it's the best solution but it does what I want. So it goes something like this: public class CustomView extends RelativeLayout { private Context context; public TextView message; public Button button; public CustomView(Context context) { super(context); // --------------------------------------------------------- // store context...

don't fill parent custom layout for action bar

android-actionbar,android-custom-view,fill-parent

change onTabSelected to this: you should define LinearLayout.LayoutParams to your custom layout actionbar public void onTabSelected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub final ActionBar actionbar = getActionBar(); View cView=null; LinearLayout.LayoutParams param = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); switch (tab.getPosition()) { case 0: cView = getLayoutInflater().inflate(R.layout.calculate_actionbar_layout, null); cView.setLayoutParams(param);...

Draw on the image instead of image view in android

android,android-canvas,android-view,android-custom-view,android-drawable

You should possibly use SurfaceView instead. It is more advanced compared to ImageView. Refer to this for drawing: http://examples.javacodegeeks.com/android/core/ui/surfaceview/android-surfaceview-example/ This is for zoom: http://android-innovation.blogspot.co.nz/2013/07/how-to-implement-pinch-and-pan-zoom-on.html...

What Library and widgets should I use in order to develop a kind of side-sliding bar?

android-custom-view,slidingdrawer

Ok, I have looked around and I found approaches to implement what I want Here and here.

Add EditText to Toolbar

android,android-edittext,android-custom-view,toolbar

Just add the EditText to the XML for your ToolBar. That is probably the easiest way. <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> <EditText android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/myEditText"...

Superpose many image View on an ImageView in a customView

android,android-layout,view,android-custom-view

If i understood correctly, you can use a RelativeLayout with as many ImageViews as you want. For example: <RelativeLayout android:id="@+id/frame_layout" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:id="@+id/card_11" android:layout_width="@dimen/card_width" android:layout_height="@dimen/card_height" android:src="@drawable/carte_vierge_bleue" android:scaleType="fitXY" android:clickable="true" android:visibility="visible" android:onClick="onCardClicked"/> <ImageView...

custom view not drawing

android,android-custom-view,ondraw

In your onDraw() method the width value is getting as 0(zero).. Change this line int i = width / 4; to int i = getWidth() / 4; ...

Android getX and getY for a custom view: strange behavior

android,xml,android-layout,android-canvas,android-custom-view

pskink is totally right, you set a padding to your "base" linearlayout your plot view so when you call getX() it returns you position of plotview in its parent layout (your base linearlayout) landmark (something corresponding to 16dp). Then when you draw a circle you set circle center in plotview...

Custom View not visible

android,android-custom-view

you missed to call the super.onLayout(changed, l, t, r, b);, which is responsible to assign a position to its children. In a concrete implementation of ViewGroup, if the default implementation is enough for you, you can avoid to override this method. If you decide to extend ViewGroup instead, you have...

Android selector not working in custom view

android,selector,android-custom-view

Your layout is not clickable, it is default state for all layouts. Use setClickable(true) in custom view implementation or in xml layout android:clickable="true" You should get something like: <com.test.myapp.custom_views.CustomMainMenuButton android:layout_width="match_parent" android:layout_height="0dp" android:clickable="true" android:text="settings" android:layout_gravity="center_horizontal" android:background="@drawable/main_menu_button_selector" android:layout_weight="1" /> ...

Custom view style, android's attributes are ignored

android,android-custom-view,android-styles

You have to change the code of MyCustomView like here: ... public MyCustomView(Context context, AttributeSet attrs) { //Called by Android if <com.my.app.MyCustomView/> is in layout xml file without style attribute. //So we need to call MyCustomView(Context context, AttributeSet attrs, int defStyle) // with R.attr.customViewStyle. Thus R.attr.customViewStyle is default style for...

Custom View in Android shows up as a black box

java,android,android-custom-view

I have found the solution!!! Android expects a SurfaceView to be drawn within another thread, so I needed to call setWillNotDraw(false) in PieView's constructor. Furthermore, as Xie mentioned, creating a custom ViewGroup is kinda pointless, so I got rid of that as well. Here's my PieView class for those interested:...

Extend RecyclerView : Error Inflating Class com.example.MyRecyclerView

android,android-5.0-lollipop,android-custom-view,recyclerview,extend

You need to implement the other Constructors too: public MyRecyclerView(Context context, AttributeSet attrs) { super(context, attrs); } public MyRecyclerView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } You are creating the MyRecyclerView through XML, thus you need the Constructor with the AttributeSet Parameter....

How to check which editext textwatcher listener is called in dynamically created edittext

android,android-edittext,android-custom-view

If I understood correctly, the whole purpose of using a TextWatcher here is to dynamically add another EditText each time the previous was filled with text. For this purpose I'd simply remove the single TextWatcher instance when creating another one and add it to the new EditText. The solution uses...

Delete row from ListView created by Custom Adapter in onClickListener

android,listview,android-listview,arraylist,android-custom-view

Don't create a new AppointmentAdapter inside the AppointmentAdapter. When you try to notifyDataSetChanged() after you removed a row you then notify the wrong adapter. You notify the newly constructed adapter which is not the one that has changed data. (The newly constructed ones are not attached to the listview either...

Setting Custom Font for TextView causing the onCreate to take longer to build

android,android-custom-view,android-fonts

Typeface.createfromassets is a time taking process. You should declare typeface as static varaiable in class and just use it in constructor. But here you are loading fonts in every textview's constructor. If you having multiple fonts, have all tytypeface as static and use it appropriately. UPDATE CODE: public class TextViewFont...

Custom list view is not replacing the view

android,android-listview,android-custom-view,baseadapter

What should i do to replace the view every time a button is clicked? Instead of adding new object of Adapter in ListView do it as: 1. Create a method in BlockAdapter to clear all data: public void refeshAdapterData(List category_Id,<Data_Type> prgmImages ) { category_Id.clear(); // clear prgmImages // add...

How to add a custom view in another custom view in Android?

android,android-custom-view

To create a custom ViewGroup, the only method you need to override is onLayout. The onLayout is triggered after the ViewGroup itself has finished laying itself out inside its own container ViewGroup and is now responsible for laying out its children. It should call the layout method on all...

How does a custom view get data from the activity?

android,callback,android-custom-view

You can get the context and cast it to your activity. And you can call public methods of your activity.

Android: Customizing action bar

android,android-actionbar,android-custom-view

If your minSdkVersion is 11 or higher then write getActionBar().setBackgroundDrawable(new ColorDrawable("COLOR")); in your .class file's onCreate() method. Now your class should look like, Class MyActivity extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_activity); getActionBar().setBackgroundDrawable(new ColorDrawable("YourColor")); } } ...

Unable to display the created CustomView

android,android-custom-view

Just overwrite your code with my code it's working. You just make mistake while retrieving attributes. Don't forget to add your package name at first line import java.text.SimpleDateFormat; import java.util.Calendar; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; import android.util.AttributeSet; import android.widget.TextView; public class TimeView extends TextView { public String titleText; public...

Outline of person's face on android camera

android,xml,android-camera,android-custom-view

Here you go there is a section detailing how to do this. http://developer.android.com/guide/topics/media/camera.html#custom-camera...

How to implement Rounded Corner Effect in a List

android,android-listview,android-custom-view

On the 1 code example, the use created a custom adapter to display alist of items, something like MyCustomeAdapter extends BaseAdapter Where as in your code you simply displayed already build in adapter, which do not support to Override getView() method in which all this changes can be made. So,...

Style for custom view extended from ToggleButton set programatically

android,android-custom-view,android-styles

You can't set style programmatically, the good way is to set style in xml and then inflate it. Take a look in this answer to confirm and second one which describes more ways to do that. And one more example.

What are the limitation in EditMode for custom views in Android?

android,android-view,android-custom-view,editmode

Custom views should work just fine as long as they only call parts of the view framework, not any application code. That's a good separation to have for views anyway: they should contain view state, not app logic. Typically you only have to use View#isInEditMode if your custom view is...

CursorAdapter with custom view not updating correctly during scroll

android,android-custom-view,android-adapter

I found the solution - it was two problems. First, there is no guarantee of onSizeChanged executing while scrolling. I moved the logic to onMeasure and ensured I was calling requestLayout() to get the proper diameter. Second, adapters re-use visuals. This means you have to update every property to ensure...

Android TableLayout contains custom view only displays first row

android,android-custom-view,android-tablelayout

I found that I need to override onMeasure() in my custom view if I want to use WRAP_CONTENT for the custom view's layout param so that the parent layout which is the TableLayout can correctly recognize the height of the custom view and then display it correctly. this post has...

Add multiple custom views to layout programmatically

android,xml,android-layout,android-custom-view

You can inflate the layout2.xml file, edit the texts, and add it to the first layout : public class MyActivity extends Activity { private ViewGroup mLinearLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout1); mLinearLayout = (ViewGroup) findViewById(R.id.linear_layout); addLayout("This is text 1", "This is first button", "This is second Button");...

How to remove divider from actionbar in Android?

android,android-actionbar,android-custom-view

I have the same problem before. Set windowContentOverlay to null will make it has no divider. In your style xml file, put this: <item name="android:windowContentOverlay">@null</item> and become <style name="AppTheme" parent="AppBaseTheme"> <item name="android:windowActionBarOverlay">true</item> <item name="android:actionBarDivider">@android:color/transparent</item> <item name="android:ratingBarStyle">@style/RatingBarAppTheme</item> <item...

How get the size or the image from DrawableLeft in EditText

android,android-edittext,android-custom-view,custom-view

as it is written public void setCompoundDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) if left, try this int width = editText.getCompoundDrawables()[0].getMinimumWidth(); int height = editText.getCompoundDrawables()[0].getMinimumHeight(); ...

Calling custom view from main activity.. Message in onDraw() is printed but custom view is not rendered

android,render,android-custom-view,ondraw

The problem is in your layout. Both your custom View and the ImagView are, since your are using a RelativeLayout, aligned to the Top left. The z order in this case put the ImageView on top on your custom View and, since it is taking the whole screen, you can't...

How to start a new Activity from a CustomView?

java,android,android-layout,android-activity,android-custom-view

Inside your LinearLayout extending class, you could create the following method: public void launch() { Intent i = new Intent(getContext(), YourActivity.class); getContext().startActivity(i); } Use the getContext() method inside your customview to retrieve the Context and start a new Activity....

Custom TextView pass data to onDraw

android,android-textview,android-custom-view

You're initializing category to the BorderTextView defined in the layout, but then you're instantiating a new instance of BorderTextView and assigning it to category. The instance you're calling setParameters() on is not the on-screen instance, and is therefore not the instance being drawn. Remove the line: category = new BorderTextView(getActivity(),...

how to call a function that's in a custom View from an activity

java,android,button,android-custom-view

public class MainActivity extends Activity { GView mGView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); // initialize here mGView = (GView)findViewById(R.id.gview); // put this anywhere and make sure you do not violate UI thread constraint for making any UI changes mGview.<yourmethod>() ... ...

Android-getting value of first row in customListview(shared preference)

java,android,null,android-custom-view

commit() method also need to call to save values in SharedPreferences s2=edittext.getText().toString(); spe.putString("quty", s2); spe.commit(); //OR if Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD spe.apply(); ...

How to implement Custom listview text animation

android,android-animation,android-custom-view

The goal is to animate the view from one location to another location so first we need to get the two points. You can do the following: int[] screenLocation = new int[2]; textView.getLocationOnScreen(screenLocation); int startX = screenLocation[0]; int startY = screenLocation[1]; int[] screenLocationB = new int[2]; cartView.getLocationOnScreen(screenLocationB); int endX =...

Fragment vs. Custom View in Android

android,fragment,android-custom-view

Fragment can be used in different scenarios but most used are: wrapper around a view headless fragment - i.e. no view => not very helpful in general but can be used retainable fragment - can be any of above. By using Fragment.setRetainInstance(true) you can bypass Fragment.onDestroy(), i.e. can keep fragment...

Item picker in Android like NumberPicker

android,listview,android-custom-view,numberpicker

The widget you're looking for is called WheelPicker and as always, there's already 3rd party libs just for this. Have a look. In landscape mode the list should appear on the left half of the screen with a selection band that is vertically centered. This could easily be done using...

Create a “ Pressed State” for a relative layout

android,android-layout,android-xml,android-custom-view,android-ui

You have to write your own selector: http://developer.android.com/guide/topics/resources/color-list-resource.html Create a xml file in your res/drawable/ folder and apply it as background to your button: my_background_selector.xml: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/background_gradient_pressed" /> <item android:state_focused="true"...

How to use soundPool in a custom view class? [closed]

java,android,android-activity,android-custom-view,soundpool

To call soundPool.play from MyView class pass MainActivity class context to using MyView constructor : MainActivity mActivity; public MyView(Context context,MainActivity mActivity) { super(context); this.mActivity=mActivity; } From MainActivity create MyView class object as: MyView v = new MyView(getApplicationContext(),this); Now use mActivity for accessing methods from MainActivity : To get SoundPool object...

Working custom view not chaning when I set params in xml (preview issue)

android,android-custom-view

You aren't calling setMeasuredDimension with the new dimensions of the view. That's going to cause problems. From the docs: CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int,...