[android-beginners] cannot remove listview items
Hi all,, Can somebody please give me an example code of removing all ListView items and replacing with new items. I tried replacing the adapter items.Still no results. my code is at first i am calling populateList(){ results -populated arraylist with strings ArrayAdapterString adapter = new ArrayAdapterString(this, android.R.layout.simple_list_item_1, results); listview.setAdapter(adapter); adapter.notifyDataSetChanged(); listview.setOnItemClickListener(this); } // now populating list again repopulateList(){ results1-populated arraylist with strings ArrayAdapterString adapter1 = new ArrayAdapterString(this, android.R.layout.simple_list_item_1, results1); listview.setAdapter(adapter1); adapter1.notifyDataSetChanged(); listview.setOnItemClickListener(this); } Here replpulateList() method will add to listview items. It doent remove/replace all listview items. Please Help. Thanks Kavitha -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en To unsubscribe, reply using remove me as the subject.
Re: [android-beginners] cannot select target when creating new project
thanks for all the responses. I tried setting home directory,bash profile,,it was same. Atlast I figured out problem,,, the build target was condensed,,,i tried moving dock bar to left and expanding the new project dialog. It was showing the build targets. Thanks kavitha On Thu, Mar 25, 2010 at 4:11 PM, Alan Cassar alan.cas...@ricston.comwrote: Did you set the sdk path in eclipse? Windows - Preferences - Android - Sdk Location Cheers Alan On 25/03/2010 08:23, kavitha wrote: Hi All I am not able to select build target when i create new project in android eclipse on mac system. I have installed eclipse-java-cocoa 32 bit version and ADT-0.96 version. This was a fresh installation and i also installed AVD and SDK Manager and have created 2 avd's. I tried creating bash profile. Even then i am not able to select build target,,the targets are not visible at all. I have attached image to show how it looks in eclipse. please help. Thanks Kavitha -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en To unsubscribe from this group, send email to android-beginners+ unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en To unsubscribe from this group, send email to android-beginners+ unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en To unsubscribe from this group, send email to android-beginners+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: [android-beginners] Re: Populate ListView inside a Activity
create an ArrayAdapter and add list items to it. then use list.setAdapter(adapter); On Thu, Mar 11, 2010 at 5:22 AM, Kitzy kitzyk...@gmail.com wrote: Search for how to fill an ArrayAdapter with an xml file, there are also examples which come with the sdk examples. You should create an array file in your res/values directory and you will have to have all the contries you want lited in it. -Kitzy On Mar 7, 12:46 pm, plexus andersthu...@gmail.com wrote: How can I populate array COUNTRIES to the ListView list @+id/ lKompListe ? = XML = ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent LinearLayout android:id=@+id/LinearLayout01 android:layout_height=wrap_content android:layout_width=fill_parent Button android:layout_width=wrap_content android:layout_height=wrap_content android:id=@+id/ buttonTilbake android:text=Tilbake/Button TextView android:layout_width=wrap_content android:layout_height=wrap_content android:id=@+id/textTittel android:layout_weight=1 android:textSize=18dp android:textStyle=bold android:layout_gravity=center android:gravity=center android:text=Velg komponent/TextView Button android:id=@+id/Button01 android:layout_width=wrap_content android:layout_height=wrap_content android:text=Endre android:visibility=invisible/Button /LinearLayout ListView android:layout_width=wrap_content android:layout_height=wrap_content android:layout_weight=1 android:id=@+id/lKompListe/ListView /LinearLayout = JAVA = public class VelgKomponent extends Activity { Button tilbake; Intent intent; ListView list; static final String[] COUNTRIES = new String[] { Afghanistan, Albania, Algeria, American Samoa }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.velgkomp); tilbake = (Button) findViewById(R.id.buttonTilbake); View.OnClickListener handler = (new View.OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.buttonTilbake: // doStuff intent = new Intent(v.getContext(), ShoppingBasket.class); startActivity(intent); break; } } }); findViewById(R.id.buttonTilbake).setOnClickListener(handler); list = (ListView) findViewById(R.id.lKompListe);} -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups Android Beginners group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Re: Please help in getting screen coordinates of a view
Hi Jark, Here is my code package com.android.table; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.view.Display; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.RelativeLayout; import android.graphics.Rect; public class GameDemo extends Activity { public static int idLayout = 1; public static int screenheight = 0; public static int screenwidth = 0; public AddPegHoles adp = new AddPegHoles(this); public Hole h; public static int holeid = 0; Hole[] holeArray = new Hole[33]; FrameLayout l1,l2,l3,l4,; RelativeLayout layout; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); layout=(RelativeLayout) findViewById(R.id.tableviewback); layout.setBackgroundResource(R.drawable.woodenbackground); Display display; display = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); screenheight = display.getHeight(); screenwidth = display.getWidth(); l1=(FrameLayout)findViewById(R.id.frame1); adp.addPegHoles(l1, 1,0); createHole(holeid,true,R.id.frame1,1); l2=(FrameLayout)findViewById(R.id.frame2); adp.addPegHoles(l2, 1, leftpadding+l1.getWidth()); holeid++; createHole(holeid,true,R.id.frame2,1); l3=(FrameLayout)findViewById(R.id.frame3); adp.addPegHoles(l3, 1, leftpadding+l1.getWidth()); holeid++; createHole(holeid,true,R.id.frame3,1); int leftpadding=(screenwidth/7); int toppadding=(screenheight/7); On Mon, Mar 23, 2009 at 5:28 PM, Jark Reijerink jark.reijer...@gmail.com wrote: Hello, Are you sure you're getting a valid FrameLayout? Because if findViewById doesnt finds a valid view it returns null. Which could explain the NullPointerException. Also: are you setting your xml layout with setContentView in your onCreate method? If so try putting your code after that method call. Jark 2009/3/23 kavitha kavith...@gmail.com Hii All, I am developing a game in android and i want to capture screen coordinates of a view(ImageView) which is embedded in frame. Hierarchy is LinearLayout android android:layout_height=fill_parent android:layout_width=fill_parent RelativeLayout android:layout_height=fill_parent android:layout_width=fill_parent FrameLayout android:layout_height=wrap_content android:layout_width=wrap_content android:id=@+id/frame14/FrameLayout /RelativeLayout /LinearLayout At run time i am attaching two image views for frame layout.I wanted to capture screen coordinates of frame layout.But Couldnt do it.if i say (FrameLayout) f=(FrameLayout)findViewById(R.id.frame14); int[] loc = new int[2]; f.getLocationOnScreen(loc); System.out.println(loc[0]); System.out.println(loc[1]); I get Null Pointer Exception for getLocationOnScreen() method. If I try to get f.getLeft() and f.getRight() they return as 0 coordinates. Can anyone please tell me how to find location on screen of a view. I tried even in onStart() method,,,still i get Null Pointer Exception. Please tell me how to get screen coordinates of a view in android. It is very urgent.Please help. Thanks Kavitha --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: Please help in getting screen coordinates of a view
FrameLayout android:layout_height=wrap_content android:layout_width=wrap_content android:id=@+id/frame3/FrameLayout /RelativeLayout Can anybody help on this Thanks Kavitha On Mon, Mar 23, 2009 at 5:28 PM, Jark Reijerink jark.reijer...@gmail.com wrote: Hello, Are you sure you're getting a valid FrameLayout? Because if findViewById doesnt finds a valid view it returns null. Which could explain the NullPointerException. Also: are you setting your xml layout with setContentView in your onCreate method? If so try putting your code after that method call. Jark 2009/3/23 kavitha kavith...@gmail.com Hii All, I am developing a game in android and i want to capture screen coordinates of a view(ImageView) which is embedded in frame. Hierarchy is LinearLayout android android:layout_height=fill_parent android:layout_width=fill_parent RelativeLayout android:layout_height=fill_parent android:layout_width=fill_parent FrameLayout android:layout_height=wrap_content android:layout_width=wrap_content android:id=@+id/frame14/FrameLayout /RelativeLayout /LinearLayout At run time i am attaching two image views for frame layout.I wanted to capture screen coordinates of frame layout.But Couldnt do it.if i say (FrameLayout) f=(FrameLayout)findViewById(R.id.frame14); int[] loc = new int[2]; f.getLocationOnScreen(loc); System.out.println(loc[0]); System.out.println(loc[1]); I get Null Pointer Exception for getLocationOnScreen() method. If I try to get f.getLeft() and f.getRight() they return as 0 coordinates. Can anyone please tell me how to find location on screen of a view. I tried even in onStart() method,,,still i get Null Pointer Exception. Please tell me how to get screen coordinates of a view in android. It is very urgent.Please help. Thanks Kavitha --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: Please help in getting screen coordinates of a view
Can anybody help on this Thanks Kavitha On Mon, Mar 23, 2009 at 5:28 PM, Jark Reijerink jark.reijer...@gmail.com wrote: Hello, Are you sure you're getting a valid FrameLayout? Because if findViewById doesnt finds a valid view it returns null. Which could explain the NullPointerException. Also: are you setting your xml layout with setContentView in your onCreate method? If so try putting your code after that method call. Jark 2009/3/23 kavitha kavith...@gmail.com Hii All, I am developing a game in android and i want to capture screen coordinates of a view(ImageView) which is embedded in frame. Hierarchy is LinearLayout android android:layout_height=fill_parent android:layout_width=fill_parent RelativeLayout android:layout_height=fill_parent android:layout_width=fill_parent FrameLayout android:layout_height=wrap_content android:layout_width=wrap_content android:id=@+id/frame14/FrameLayout /RelativeLayout /LinearLayout At run time i am attaching two image views for frame layout.I wanted to capture screen coordinates of frame layout.But Couldnt do it.if i say (FrameLayout) f=(FrameLayout)findViewById(R.id.frame14); int[] loc = new int[2]; f.getLocationOnScreen(loc); System.out.println(loc[0]); System.out.println(loc[1]); I get Null Pointer Exception for getLocationOnScreen() method. If I try to get f.getLeft() and f.getRight() they return as 0 coordinates. Can anyone please tell me how to find location on screen of a view. I tried even in onStart() method,,,still i get Null Pointer Exception. Please tell me how to get screen coordinates of a view in android. It is very urgent.Please help. Thanks Kavitha --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Urgent help in getting screen coordinatesof a view
=@+id/frame3/ FrameLayout /RelativeLayout Thanks Kavitha --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: Please help in getting screen coordinates of a view
Hi Jark, I changed from onStart() to onResume(),But still it prints as o for everything. Is there any other way to get screen coordinates,,any suggestions please. Thanks Kavitha On Tue, Mar 24, 2009 at 12:07 PM, Jark Reijerink jark.reijer...@gmail.com wrote: Hi Kavitha, If i look at the the Activity lifecycle -- http://developer.android.com/reference/android/app/Activity.html I see that when the onStart() method is called the activity is becoming visible, can you try changing onStart() into onResume()? With kind regards, Jark 2009/3/24 kavitha kavith...@gmail.com Hi Jark, I tried to print the view coordinates,they print value as 0. If i say v.getLeft() even that print it's value as 0. I am not understanding.Please help on this regard.It displays frame and images correctly in position. Here is my code.I am trying to print view values in onStart() package com.android.table; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.view.Display; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.RelativeLayout; import android.graphics.Rect; public class GameDemo extends Activity { public static int idLayout = 1; public static int screenheight = 0; public static int screenwidth = 0; public AddPegHoles adp = new AddPegHoles(this); public Hole h; public static int holeid = 0; Hole[] holeArray = new Hole[3]; - Show quoted text - FrameLayout l1,l2,l3,l4,; RelativeLayout layout; /** Called when the activity is first created. */ �...@override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); layout=(RelativeLayout) findViewById(R.id.tableviewback); layout.setBackgroundResource(R.drawable.woodenbackground); Display display; display = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); screenheight = display.getHeight(); screenwidth = display.getWidth(); l1=(FrameLayout)findViewById(R.id.frame1); adp.addPegHoles(l1, 1,0); createHole(holeid,true,R.id.frame1,1); l2=(FrameLayout)findViewById(R.id.frame2); adp.addPegHoles(l2, 1, leftpadding+l1.getWidth()); holeid++; createHole(holeid,true,R.id.frame2,1); l3=(FrameLayout)findViewById(R.id.frame3); adp.addPegHoles(l3, 1, leftpadding+l1.getWidth()); holeid++; createHole(holeid,true,R.id.frame3,1); int leftpadding=(screenwidth/7); int toppadding=(screenheight/7); ViewGroup child=(ViewGroup)layout.getChildAt(0);//frame1 child.setPadding(45*2, 45, 0, 0); child=(ViewGroup)layout.getChildAt(1); // frame2 child.setPadding(45*3, 45, 0, 0); child=(ViewGroup)layout.getChildAt(2); //frame3 child.setPadding(45*4, 45, 0, 0); } public void onStart(){ super.onStart(); int[] loc=new int[2]; View v = layout.getChildAt(1); v.getLocationOnScreen(loc); System.out.println(loc[0]+loc[1]); System.out.println(v.getLeft()); System.out.println(v.getRight()); v=(FrameLayout)findViewById(R.id.frame1); v.getLocationOnScreen(loc); System.out.println(loc[0]+loc[1]); System.out.println(v.getLeft()); System.out.println(v.getRight()); } public void createHole(int holeid, boolean filled, int parent_frame_id, int parentrow) { h = new Hole(holeid); h.setHoleId(R.drawable.hole); h.setHoleIndex(0); h.setFilled(filled); h.setParentFrameId(parent_frame_id); h.setParentRow(parentrow); h.setMarbleId(R.drawable.marble); h.setMarbleIndex(1); holeArray[holeid] = h; } } And I am adding imageviews for frame in AddPegHoles.java looks like this package com.android.table; import android.content.Context; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; public class AddPegHoles { public Context context; public static int id=0; AddPegHoles(Context c){ super(); this.context=c; } public void addPegHoles(ViewGroup v,int row,int leftpadding){ ImageView iv1=new ImageView(context); iv1.setImageResource(R.drawable.hole); ImageView iv11=new ImageView(context); iv11.setImageResource(R.drawable.marble); id++; v.setId(id); v.addView(iv1,0);v.addView(iv11,1); } } And my AndroidManifest.xml looks
[android-beginners] Re: need help in getting screen coordinates of a view
Hi Romain Guy,, Thanks for the reply. I am very new to android.Could you please tell me an example of doing this??I am very new to android. Looking for your reponse. Thanks Kavitha On Mon, Mar 23, 2009 at 7:48 AM, Romain Guy romain...@google.com wrote: You can only do this after onCreate(), after all the views have been positioned. On Sun, Mar 22, 2009 at 10:03 AM, kavitha kavith...@gmail.com wrote: Hii All, I am developing a game in android and i want to capture screen coordinates of a view(ImageView) which is embedded in frame. Hierarchy is LinearLayout android android:layout_height=fill_parent android:layout_width=fill_parent RelativeLayout android:layout_height=fill_parent android:layout_width=fill_parent FrameLayout android:layout_height=wrap_content android:layout_width=wrap_content android:id=@+id/frame14/FrameLayout /RelativeLayout /LinearLayout At run time i am attaching two image views for frame layout.I wanted to capture screen coordinates of frame layout.But Couldnt do it.if i say (FrameLayout) f=(FrameLayout)findViewById(R.id.frame14); int[] loc = new int[2]; f.getLocationOnScreen(loc); System.out.println(loc[0]); System.out.println(loc[1]); I get Null Pointer Exception for getLocationOnScreen() method. If I try to get f.getLeft() and f.getRight() they return as 0 coordinates. Can anyone please tell me how to find location on screen of a view. It is very urgent.Please help. Thanks Kavitha -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Please help in getting screen coordinates of a view
Hii All, I am developing a game in android and i want to capture screen coordinates of a view(ImageView) which is embedded in frame. Hierarchy is LinearLayout android android:layout_height=fill_parent android:layout_width=fill_parent RelativeLayout android:layout_height=fill_parent android:layout_width=fill_parent FrameLayout android:layout_height=wrap_content android:layout_width=wrap_content android:id=@+id/frame14/FrameLayout /RelativeLayout /LinearLayout At run time i am attaching two image views for frame layout.I wanted to capture screen coordinates of frame layout.But Couldnt do it.if i say (FrameLayout) f=(FrameLayout)findViewById(R.id.frame14); int[] loc = new int[2]; f.getLocationOnScreen(loc); System.out.println(loc[0]); System.out.println(loc[1]); I get Null Pointer Exception for getLocationOnScreen() method. If I try to get f.getLeft() and f.getRight() they return as 0 coordinates. Can anyone please tell me how to find location on screen of a view. I tried even in onStart() method,,,still i get Null Pointer Exception. Please tell me how to get screen coordinates of a view in android. It is very urgent.Please help. Thanks Kavitha --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---