android-custom-view

How to add a clickable “events” action item to actionBarSherlock?

限于喜欢 提交于 2019-12-11 11:38:44
问题 Background many apps (including google plus and facebook) have an action bar item showing the number of in-app-events (or "notifications"). This action item has a number within it and you can click it in order to show the events the app has for the user. something like that (taken from here) : The problem I wish to make it work on old android versions, so i use actionBarSherlock. Sadly, each solution i use has its disadvantages, and i couldn't find any solution here (on stackOverflow) that

text customization for Infinite Scrolling Gallery

不想你离开。 提交于 2019-12-11 11:07:42
问题 I have infinite gallery based on this example : http://blog.blundell-apps.com/infinite-scrolling-gallery/, every thing run ok : exactly i want to applied text to each image and able to customize text too as shown down image ,and each image has diffrenet text than others , but still not succeed to do it with infinite gallery I tried with following code but it gave me FORCE CLOSE when running the app , ( MAYBE THERE IS WRONG CODES I WROTE , BUT IM STILL LEARNING JAVA AND BEGINER IN ANDROID

postInvalidate() not working with non-ui Thread

放肆的年华 提交于 2019-12-11 08:25:51
问题 I am using a custom view to draw a game content and i use a button from xml layout to enable or disable the drawing of a specific content(rectangle) using separate thread.I managed to have the thread running but postInvalidate() method that i use is being ignored.I tried using setWillNotDraw(false) too.It isn't working.I've condensed my code,to be specific on which part of the code i have this problem. activity_main.xml <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http:/

Repeat a task with a time delay inside a custom view

扶醉桌前 提交于 2019-12-11 07:32:42
问题 The question Repeat a task with a time delay? talks about a repeated task within an activity. The top voted answer looks good for that situation. I am trying to make a blinking cursor inside a completely custom EditText. I tried copying and adapting code from the Android TextView and Editor code, but I wasn't getting anything to blink. Here is some of the current code I have been trying to get to work: private boolean shouldBlink() { if (!mCursorVisible || !isFocused()) return false; final

ClassCastException when initializing CustomView

佐手、 提交于 2019-12-11 07:26:54
问题 I have a custom TextView looking like this: public class ClickTextView extends TextView { public ClickTextView(Context context, AttributeSet attrs) { super(context, attrs); } // and so on... } Why is the code below giving me a ClassCastException? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // CLASS CAST EXCEPTION HERE, this is line 69 ClickTextView tvClicks = (ClickTextView) findViewById(R.id.tvClicks); }

Rotate CustomView without affecting the activity

别等时光非礼了梦想. 提交于 2019-12-11 06:13:00
问题 Hi I have a floating window in which my floating window serves as the video and it also have a controls inside the video which under the floating window Now my question is it possible that I can rotate my custom view from floating window only without affecting the orientation of my activity If someone already tried it please guide me towards it. Thank you. 回答1: I have never done it before. But I have an idea. You can use the below code to get the current orientation of the screen on your

push whole dialog above the keyboard, keyboard covers button

↘锁芯ラ 提交于 2019-12-11 04:25:43
问题 I have custom dialog which is attached to bottom of the screen. When I focus to the edittext, keyboard opens but it focuses to edittext so covers my button. I want to see the button. If I use same xml in activity it behaves correctly I tried all of the windowSoftInputMode's but didn't work, I also put my whole view in scrollview it also didn't work. My dialog XML , (I believe problem is here) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk

How to implement onClickListener only when is image click?

自闭症网瘾萝莉.ら 提交于 2019-12-11 03:56:36
问题 I have image like pieces of pizza, and I want implement onClickListener only when I click on pizza? 回答1: pizzaImageView.setClickable(true); pizzaImageView.setOnClickListener(pizzaClickListener); private OnClickListener pizzaClickListener = new OnClickListener() { public void onClick(View view){ //Do code here } }; 来源: https://stackoverflow.com/questions/16315610/how-to-implement-onclicklistener-only-when-is-image-click

Trying to use custom imageview (topcrop) in android, but the the app stops

偶尔善良 提交于 2019-12-11 03:31:18
问题 I found the following post How set imageview scaletype to topCrop Based on that i used the class TopCropImageView from https://gist.github.com/arriolac/3843346 which extends ImageView The following is my layout xml file <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <com.simha.quotes.TopCropImageView android:layout_width=

Set individual onClick events in custom ViewGroup

大憨熊 提交于 2019-12-11 02:37:26
问题 I have created a custom ViewGroup in which I create a couple of custom child Views (in the java code, not xml). Each of these childs needs to have the same onClick event. The method to handle these click events resides in the activity class that uses the layout. How do I set this method as the onClick handler for all child views? Here is my code simplified. The custom ViewGroup: public class CellContainerGroup extends ViewGroup { CellView[][] CellGrid = new CellView[9][9]; public