custom-view

How to create a custom UIView?

跟風遠走 提交于 2019-12-23 04:26:15
问题 I've created a UIView subclass and corresponding xib file where I've laid out some UILabels and UIImageViews. I want to then put multiple copies of this custom UIView into a UIViewController. When I do that they appear blank in interface builder and don't appear when the app loads. What methods do I need to implement on the UIView subclass to make this work? 回答1: The easiest method by far is to create a nib with File's Owner set to NSObject, containing one view containing your layout element.

Change custom button size for layouts and containers

无人久伴 提交于 2019-12-22 08:12:06
问题 I have a custom class (touchbutton) extending the TextView class. I am having trouble resizing the button manually. I can get the button to work for only one type of layout or container, but not both. For the most part, Touchbutton is in gridviews so my method to change the size is as so: private void setLayout(buttonsize_t size) { log("Setting Layout: "+buttonsize_t.getPxl(size)); final float scale = getContext().getResources().getDisplayMetrics().density; int dim = (int) (buttonsize_t

How to getGravity() in custom view?

瘦欲@ 提交于 2019-12-22 05:06:51
问题 Can't get gravity attribute ( android:gravity ) from my CustomView. XML <MyCustomView ... android:gravity="right" /> My Custom View; class MyCustomView extends LinearLayout{ ... @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { getGravity(); //Throws method not found exception ((LayoutParams)getLayoutParams()).gravity; //This returns the value of android:layout_gravity super.onMeasure(widthMeasureSpec, heightMeasureSpec); } ... } getGravity(); throws method not

Can a custom View know that onPause has been called?

有些话、适合烂在心里 提交于 2019-12-20 10:31:08
问题 I have a custom View that runs a Thread operation which sits around making calls to the interwebs periodically. I would like to know if there's a way for me to not have to kill that thread from the parent Activity (onPause) so that the Thread isn't milling about in the background after the Activity has been backgrounded (and/or killed). The intention here is for the custom View to be self sufficient and not need additional handling from the Activity. The way to do that would be for it to

Custom Checkable View which responds to Selector

断了今生、忘了曾经 提交于 2019-12-20 08:50:01
问题 I have a group of FrameLayout which I want to be checkable/selectable, That is, after a click I would like the FrameLayout to display as checked - when pressed again I would like it to become un checked . What's more, I want this visual que to be described as usual through though the use of a <selector> . I can't seem to get this working - I'm not sure what I'm missing: public class CheckableFrameLayout extends FrameLayout implements Checkable { private boolean mChecked = false; public

How to remove NSMenuItem gap above custom view

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 07:14:23
问题 I was looking for something discussed in following posts. Gap above NSMenuItem custom view. Reverse engineering an NSMenu for a Status Bar Item I tried the carbon code provided by Pierre Bernard initially, i was getting same error "EXC_BAD_ACCESS on the line InstallControlEventHandler" like other had. I play with the code lots and accidently found the solution. I have just replaced the InstallControlEventHandler function call to HIViewInstallEventHandler and everything is working fine. Hope

Android Custom View Constructor

烂漫一生 提交于 2019-12-17 04:55:21
问题 I'm learning about using Custom Views from the following: http://developer.android.com/guide/topics/ui/custom-components.html#modifying The description says: Class Initialization As always, the super is called first. Furthermore, this is not a default constructor, but a parameterized one. The EditText is created with these parameters when it is inflated from an XML layout file, thus, our constructor needs to both take them and pass them to the superclass constructor as well. Is there a better

View in Android taking the whole screen- how to tell the canvas to respect the limits of the view?

你离开我真会死。 提交于 2019-12-14 02:32:00
问题 EDIT: OK, so I've extended the lenght and the width of the view to a big part of the screen I can assume that the onDraw() method is NOT TAKING the limits of the view, because it goes through all the screen as I can suppose. So the question now would be how to tell the canvas to respect the limits of the view? Any ideas, maybe forcing some parameters? END OF EDIT I have implemented some code for drawing a custom view, but the canvas is blank. I am sure it is running, because I have added log

extjs 4 how to wrap children components of container in custom html?

北慕城南 提交于 2019-12-13 04:33:10
问题 I need to create Twitter Bootstrap basic NavBar component in my ExtJS 4.2 application. All I want to make my component generate the following html: <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <ul class="nav"> <li class="active"><a href="#"><i class="icon1"></i> Item #1</a></li> <li><a href="#"><i class="icon2"></i> Item #3</a></li> <li><a href="#"><i class="icon3"></i> Item #3</a></li> </ul> </div> </div> I've created two views (NavBar and NavBarItem

How to add CustomView to Layout fromXML?

微笑、不失礼 提交于 2019-12-13 01:26:07
问题 I want to add this PaintingView() that is in this Activity from XML file. public class Full extends Activity implements ColorPickerDialog.OnColorChangedListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.paint); FrameLayout myFrameLayout = (FrameLayout) findViewById(R.id.framelayout); myimage = (ImageView) findViewById(R.id.ImageView01); InputStream is = this.getResources().openRawResource(imageId1);