Android :: How To Clone View Object / Can Be Added To Current View Hierarchy?

Feb 28, 2010

I like to know how can i clone a view object which is already there in the view hierarchy, so that it can be added to the same view hierarchy again.

Android :: How to clone View object / can be added to current view hierarchy?


Android :: Clone View At Object Level For Performance Reason?

Nov 11, 2010

My question is almost exactly this question:
Clone textview to append it to a ViewGroup
However, I was inflating a view, and then attempting to clone it at the object level for performance reasons (I don't want to parse XML every single time), so that answer doesn't help me. View.clone() is protected and it apparently doesn't have a copy constructor. Is there any way to do this?

View 1 Replies View Related

Android :: Want To Get Current Focus View Object In Service?

Nov 18, 2010

I want to get the current focus view in my Service to check the view is a EditText and append some texts in it (for all EditTexts, not only in my application).

I found some methods to do this, like Activity.getCurrentFocus() and Windows.getCurrentFocus(). But these methods are used in a Activity.

How can I use these methods in a Service? Or is there another way to do?

View 2 Replies View Related

Android : How To Replace Current View By Another View?

Jan 21, 2009

I need to replace the current View (set by the activity.setContentView method) by an other.

View 10 Replies View Related

Android :: Propagate Attribute Value Through View Hierarchy

Feb 10, 2009

I have attribute "attr1" defined for my views A, B, C. A and B are actually ViewGroups. Let's say C is contained in B and B in A. Is there an existing mechanism in Android framework that allows me to specify the value of attr1 in A and have it automatically propagated to B and C?

View 2 Replies View Related

Android :: Adding GestureOverlayView To My SurfaceView Class - How To Add To View Hierarchy

Jul 30, 2010

I was informed in a later answer that I have to add the GestureOverlayView I create in code to my view hierarchy, and I am not 100% how to do that. Below is the original question for completeness.

I want my game to be able to recognize gestures. I have this nice SurfaceView class that I do an onDraw to draw my sprites, and I have a thread thats running it to call the onDraw etc .

This all works great.

I am trying to add the GestureOverlayView to this and it just isn't working. Finally hacked to where it doesn't crash but this is what i have

CODE:..........

The onGesturePerformed is never called. Their example has the GestureOverlay in the xml, I am not using that, my activity is simple:

CODE:................

So I am at a bit of a loss of the missing piece of information here, it doesn't call the onGesturePerformed and the nice pretty yellow "you are drawing a gesture" never shows up.

View 1 Replies View Related

Android :: Support Clone Of A View In Custom Views / Api To Use It?

May 14, 2009

Is it possible to clone a view. If no, how to support clone of a view in custom views. If yes.. which api should we use. clone method seems to be protected for view.

View 2 Replies View Related

Android :: Custom View Gets Drawn Only When Added In OnCreate / Put Call?

Nov 12, 2010

I made a "GraphBar" custom view that is a RelativeLayout with a TextView on the bottom and an ImageView, varying in height, above that. Here is the code...

I've found it's probably a bug. The workaround should be, again, calling requestLayout(). Still i don't understand where i can put the call.

View 1 Replies View Related

Android :: ListView No Longer Responding To Select When Checkbox Added To Row View

Jun 10, 2010

I'm sure this is an obvious one but I'm at a loss. I'm using my own layout for list rows, all well and fine. but the moment I add a checkbox view to the rows layout only the checkbox responds to user selection. I'd like for the checkbox to change state if the user taps anywhere within a given row. (as with android prefs)

View 2 Replies View Related

Android :: Populate View Flipper Child View With List View?

Aug 2, 2010

I am trying to set up a ViewFlipper that changes a SlidingDrawers content each time a button is pressed. So far every view I set up worked fine, but now I am trying to create a ListView (including single_choice_mode) within a child view of the ViewFlipper, but my attempt only let to a NullPointerException. As I only discovered ViewFlipper today, I am not yet familiar with it and may not have understood it completely. if someone could give me a hand and help me find out what I have done wrong, that would be great. Here is what I have done:

The code for the onClick event of the ImageButtons:
public void onClick(View v){
if (v == btnExposure){
mFlipper.setDisplayedChild(0); }
else if (v == btnProperties){
mFlipper.setDisplayedChild(1);}
else if (v == btnSpecialEffects){
mFlipper.setDisplayedChild(2);.............

View 1 Replies View Related

Android :: Get Activity Object While In View Context

Oct 10, 2010

This is a followup to this post: http://stackoverflow.com/questions/3897176/findviewbyid-in-a-subclassed-surfaceview-throwing-runtimeexception Based on Romain Guy's feedback (which I'll accept shortly as it is a solution), I'd like to obtain the calling Activity from within the View, so that I can use it to obtain the desired Text View resource. I don't see any methods in View that return Activity. What is the proper way to do this? Or is there a better alternative for working with TextViews from within another View context. Basically, I am calling setContentView(R.layout.xxx) in onCreate() (as usual), so I don't really have a way to pass in references to additional TextViews unless I awkwardly retrieve the View after setContentView and then make calls on it.

View 1 Replies View Related

Android :: Want To Set Focus To Xyz View Object Pro Grammatically

May 7, 2009

We see API for saying which is the next focusable view.. however during the event handling we want to set the focus to xyz view object pro grammatically . Is that possible.

View 3 Replies View Related

Android :: Create A 'View' Object From A Xml File?

Mar 9, 2009

In the Tab2 of TabActivity in the APIDemo example, it has this method to create a View object for each tab. code...

Can you please tell me how can I create a View for each tab from an xml layout file? For example code...

View 2 Replies View Related

Android :: Move A View Object In Circle?

Aug 7, 2009

I have a very simple requirement. I have a View object, lets say an ImageView object. I want to move this ImageView object in a circle.

More specifically, I want to move it along an arc, which is not a complete circle. I found in Android Documentation that comes with SDK that we can create a path from an arc but it does not mention how to use this path to make an animation that goes along that path.

Please note that I dont want to rotate the image. I have to move it in a circular path.

View 3 Replies View Related

Android :: Scrollbar In Adapter View Derived Object

Jan 11, 2010

I have a Adapter View derived class (say GridLayout) in which I arrange views in a grid. When items in the grid exceed the height of the GridLayout( or screen) I want a scrollbar to appear. I have handled scrolling in onTouchEvent. But the problem is the scrollbars don't appear. I have set the vertical scrollbar to be enabled, but no use. The docs say the scrollbar appears every time the scrollTo or scrollBy methods are called.

View 2 Replies View Related

Android :: Sharing Stream Object Between Activities Of Tab View

Sep 15, 2010

I want to share streams of a socket connection between the activities of a tab view. In particular the tab activity creates the socket and gets the i/o streams,so i want that tabbed activities use these streams to retrieve informations without reconnect to the server each time i switch from a tab to another. I know i can use the application class to have a global state, but i don't know how.

View 4 Replies View Related

Android :: Can An <selector> Be Based On An Object's Instead Of A View's State?

Aug 3, 2010

I think this is a pretty simple question but I'm having trouble finding the answer out there.I'm developing an android application (currently developing against v1.5 API) and one of the activities use a ListView. I want to be able to set the properties of each List Item based on the state of an in memory object rather than the state of the view or list item.Here is a simple example....say I have a Person class who's public members are defined as follows. Code...

View 1 Replies View Related

Android :: 1.6 Invalid View Object Passed To OnListItemClick()?

Dec 14, 2009

This subject originates here: http://groups.google.com/group/android-beginners/browse_thread/thread...

To sum up:

When I click on an item in the ListView, the background color that gets changed is not that of the clicked item but instead of the other item in the opposite side relative to the middle item:

1 <-- I click here 2 3 <-- Acts as a mirror 4 5 <-- This is the one that gets changed

1 2 <-- This is the one that gets changed 3 <-- Acts as a mirror 4 <-- I click here 5

This problem persists even when I use CheckedTextView like what is suggested in the post.

I use the latest stable SDK.

This problem occurs when the target platform is Android 1.6, 2.0 or 2.0.1.

The problem does not occur when the target platform is Android 1.1 or 1.5.

However, the problem will also occur when the program is compiled for 1.5 and run in 2.0.1.

The simple problematic code can be found here: [url]

There I also put the screenshots showing the problem: demo01.png: I click an item. demo02.png: the clicked item doesn't get changed but the reflective item does.

Is this a bug in newer Android platforms?

If it is intended, what is the reason and could you please show me how I should fix my code?

View 6 Replies View Related

Android :: Invoke Changes To A Custom View Object From Its Activity?

Nov 7, 2010

I have a custom view that draws to a canvas. I am trying to invoke changes to the canvas when the user pushes a button from the activity that this view is tied to. Currently, I am attempting to do this by calling a public method, called setNewDrawable, that I created inside the view.

The debugger is giving me different values for the view ID depending on whether I'm inside setNewDrawable or inside the Overridden onDraw method when I post an Invalidate.

For example the debugger variables show: (This - MyView id=830067720176) or (This - MyView id=830067712344) in setNewDrawable and onDraw respectively. This makes me think I basically have two copies of the object and I am essentially interacting with the wrong one.

How can I get information to my custom View in order to determine what it draws?

Here is the code I am running...

View 1 Replies View Related

Android :: How To Update View Object On Main Thread By Background?

Mar 3, 2009

My purpose is very simple : each 1second, I want to redraw an object on different place on background. I do not know where my error on this code below. Here is my code:
public class My_View extends View{ private Bitmap mBackground_img;
private Drawable mMoveObject; private int mObjectw,mObjecth; private int Dx,Dy;
private Handler myHandler = new Handler(); private long lasttime;
public My_View(Context context,AttributeSet ats,int ds) {
super(context,ats,ds); init(context);
} public My_View(Context context,AttributeSet ats) { super(context,ats);
init(context); } public My_View(Context context) { super(context);
init(context); } public void change() { invalidate();
} private void init(Context context) {
Resources res = context.getResources();
mMoveObject = res.getDrawable (R.drawable.lander_firing);
mBackground_img = BitmapFactory.decodeResource(res, R.drawable.my_pic);
mObjectw = mMoveObject.getIntrinsicWidth();
mObjecth = mMoveObject.getIntrinsicHeight();
Dx = Dy = 0; lasttime = System.currentTimeMillis() + 1000;
Thread mthread = new Thread(null,doBackground,"Background");
mthread.start(); } private Runnable doBackground = new Runnable() {
public void run() { long now = System.currentTimeMillis();
if(lasttime < now ) { Dx = Dx + 10; Dy = Dy + 10;
lasttime = now + 1000; myHandler.post(change_view);
} } }; private Runnable change_view = new Runnable() {
public void run() { change();
} };
@Override public void onDraw(Canvas canvas) {
canvas.drawBitmap(mBackground_img,0 ,0 , null);
mMoveObject.setBounds(Dx, Dy, Dx+mObjectw, Dy+mObjecth);
mMoveObject.draw(canvas);
} }

View 7 Replies View Related

Android :: Cannot Call Method Of View Object Inside Activity

Nov 7, 2010

In my program I have a custom view object. Inside the view class is a method called foo. For some reason when I call foo from my activity, it doesn't fire. Here is the code:

XML of the custom view:
<com.company.application.MyView android:id="@+id/my_view" android:layout_width="wrap_content" android:layout_height="wrap_content" />

The activity code:
public class Main extends Activity { MyView mView;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main);
LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = li.inflate(R.layout.main, null); mView= (MyView) v.findViewById(R.id.my_view);
//A button to fire the method inside foo() Button switchLeft = (Button) findViewById(R.id.switch_left); switchLeft.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { callTest(); } } );
} public void callTest() { Log.w(this.getClass().getName(), "clicked left arrow");
mView.foo(); mView.postInvalidate();
} }

Finally here is foo:
public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas); Log.w(this.getClass().getName(), "background set");
}

The first log is always written when the button is pressed, but the second log is not because foo never fires. What is the deal here? Upon request, the full view

public class MyView extends View { Drawable mBackground; Context mContext;
public MyView (Context context) { super(context); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public MyView (Context context, AttributeSet attrs) {
super(context, attrs); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas);
Log.w(this.getClass().getName(), "background set"); }
@Override public void onDraw(Canvas canvas) { Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL); // draw a solid blue circle
paint.setColor(Color.BLUE); canvas.drawCircle(20, 20, 15, paint);
// draw a test background mBackground.setBounds(0, 0, 300, 400);
mBackground.draw(canvas); }
}

View 1 Replies View Related

Android :: How Can I Get Current Activity Object In Instrumentation Object?

Sep 9, 2009

I want to do some automated testcase with Instrumentation . Suggest that my AUT has 2 Activity. After clicking the button in ther first Activity, the second one will be shown with new content base on what we enter in the first Activity.) Instrumentation provides us the function called startActivitySync() and return the Activity object for processing. My question is how we can get the pointer of the second Activity after the it is shown by clicking the button on the first activity.?

View 2 Replies View Related

Android :: How To Get Root View Of Current Activity?

Jun 11, 2009

Is there a function that allows me to get the top most view (the root)?

View 2 Replies View Related

Android :: Allow Anyone To View My Current Geographical Location Online?

Aug 8, 2010

I moved out of state for college & work, and whenever I am making the 8 hour drive home people are constantly bugging me about how far I am and when I'll be arriving. I don't really like texting or talking while I'm driving, so I'm looking for an app to help me out.

Is there an application that could post my current location on google maps whenever I have the app running?

Bonus points if it could be integrated into a navigation app somehow to show my trip route and basic information (e.g. how long I've been driving and estimated time of arrival).

You guys know of anything like this? Basically I want to be able to send a url to my friends or family to monitor my location.

View 4 Replies View Related

Android : Can I Use Parcel To Clone An Object?

Sep 22, 2010

I have a class which has implemented Parcelable. Can I do something like the following to create a new instance of a class?

found this from the following q: http://stackoverflow.com/questions/1626667/how-to-use-parcel-in-android

This is working ok, I can go with this but it is extra code, not sure if there's a shorter way to do it (other than properly implementing a copy constructor...)

View 1 Replies View Related

Android : Close Current Activity When An Action Happens In Custom View

Oct 13, 2010

I have a toolbar view set for most of my activities.

The toolbar has several buttons which all trigger certain intents. Now, the problem is: how can I close current activity before starting another one ?

Problem 1) Activity cones For instance one of the buttons ('A') starts activity A. Activity A also has toolbar. If you press on the 'A' button, a new A activity will be started. I suppose I can look at Activity.getInstanceCount(), right ?

Problem 2) Unnecessary activities The activity X is not needed any more if the opts for A. I just want A then. How can I remove X from toolbar which only has access to context ?

I, of course could find toolbar view inside activity X and override the onClicks, but in general this would mean doing so for all my activities !? Am I on the right track ?

View 2 Replies View Related

Android :: Close Activity Hierarchy In Droid / Show New Not Present In Current Task?

Sep 26, 2010

How do I close a whole hierarchy of activities and show a new activity not present in the current task?

Context

Consider a FTP browser that resumes the previous session on launch. Each folder is displayed in its own activity. When I click on a folder, a new activity is started for the folder. If I press the back button, the app returns to the previous activity, which corresponds to the the parent folder.

I can logoff from the menu at any time. Logging off should bring me to the login activity (not present the current task when the app has resumed the session), and close all the other activities. How can I do this?

From what I've read, if the activity were in the current task I could use FLAG_ACTIVITY_CLEAR_TOP in the intent, but this is not my case.

View 1 Replies View Related

Android : Need To Append TextViews To Current View Whenever User Hits On Button

Jun 1, 2009

I need to append a new TextView to the current View whenever a user hits on a button.

View 7 Replies View Related

SetContentView Of Activity Within Activities Current View?

Feb 17, 2012

So I have my main activity. It starts out adding a custom SurfaceView called DrawView as the content view with

DrawView drawview = new DrawView(parameters);
this.setContentView(drawview);

now my layout.main.xml is a layout with a video view which I am using to play my cutscenes. I am able to switch to this view by calling a method I made which switches the content view by

this.setContentView(R.layout.main);

which works fine when I am calling this method within the Activity. Only problem is I need to call this method from within DrawView! The method I made to switch to my cutscene is public and I do pass the Activity (named Draw) as a parameter of DrawView.

So when I do call this method from within DrawView my game freezes and will subsequently crash! however it works when method is called locally?

View 3 Replies View Related

Android :: Remove Runnable From Handler Object Added By PostDelayed?

Sep 2, 2010

I have an "open" animation and am using Handler.postDelayed(Runnable, delay) to trigger a "close" animation after a short delay. However, during the time between open and close, there is possibly another animation triggered by a click...my question is, how would I cancel the "close" animation in the handler?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved