473,471 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

array problem

59 New Member
the problem is in for loop. note Log.d prints only 0 than the my problem crashes.

this code seem right to me. is there any thing iam missing?

Expand|Select|Wrap|Line Numbers
  1. public class test extends Activity implements View.OnClickListener {
  2.  
  3. int idArray[] = { R.id.imageButton1, R.id.imageButton2, R.id.imageButton3,
  4. R.id.imageButton4, R.id.imageButton5, R.id.imageButton6,
  5. R.id.imageButton7, R.id.imageButton8, R.id.imageButton9,
  6. R.id.imageButton10, R.id.imageButton11, R.id.imageButton12,
  7. R.id.imageButton13, R.id.imageButton14, R.id.imageButton15,
  8. R.id.imageButton16, R.id.imageButton17, R.id.imageButton18,
  9. R.id.imageButton19, R.id.imageButton20, R.id.imageButton21,
  10. R.id.imageButton22, R.id.imageButton23, R.id.imageButton24,
  11. R.id.imageButton25, R.id.imageButton26, R.id.imageButton27,
  12. R.id.imageButton28, R.id.imageButton29, R.id.imageButton30,
  13. R.id.imageButton31, R.id.imageButton32, R.id.imageButton33,
  14. R.id.imageButton34, R.id.imageButton35, R.id.imageButton36,
  15. R.id.imageButton37, R.id.imageButton38, R.id.imageButton39,
  16. R.id.imageButton40, R.id.imageButton41, R.id.imageButton42,
  17. R.id.imageButton43, R.id.imageButton44, R.id.imageButton45,
  18. R.id.imageButton46, R.id.imageButton47, R.id.imageButton48,
  19. R.id.imageButton49, R.id.imageButton50, R.id.imageButton51,
  20. R.id.imageButton52, R.id.imageButton53, R.id.imageButton54,
  21. R.id.imageButton55 };
  22.  
  23. Button buttons[] = new Button[idArray.length];
  24.  
  25.  
  26. @Override
  27. protected void onCreate(Bundle savedInstanceState) {
  28.     super.onCreate(savedInstanceState);
  29.  
  30.     for (int i = 0; i < idArray.length; i++) {
  31.         Log.d("DEBUG", " "+i);
  32.         buttons[i] = (Button) findViewById(idArray[i]);
  33.         buttons[i].setOnClickListener(this);
  34.       }
  35. }
  36.  
  37.  
  38. @Override
  39. public void onClick(View view) {
  40.  
  41. }
Sep 22 '13 #1
1 1259
Nepomuk
3,112 Recognized Expert Specialist
Well, nothing that I can see is definitely wrong; however I don't know what the error message is. What exception is thrown? What is the stacktrace? Have you tried debugging this to see, where it crashes? I'm assuming it's in line 32 or 33.
Sep 22 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Robert | last post by:
Im having a problem with an array that is put into a session. I want to be able to remove any element, but when I loop through to display them, it doesnt work right. I believe its because of the...
2
by: Zenobia | last post by:
I have a problem. I need to look up several values stored in arrays. Each value is stored as a pair. The first (number) represents the probability of this item occurring. For instance, in the...
3
by: engartte | last post by:
Hi all, I did the solution with consultation of some experts on the following problem: Declare an array of length of 10 and read integers into the elements of the array from keyboard.Then...
2
by: farmer | last post by:
I need to populate a listbox of other listview with selected listview items.although the following code works perfecty I want to use an Array (for various reasons) for Each ListItem In...
0
by: helldiversafe-news | last post by:
Hi all, I will use a apache soap service with an .net c# client and have a problem with an complex array: <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope...
2
by: julian_m | last post by:
let's say that I've an array like this: $AL_array = Array ( => Array ( => 1 ) , => Array ( => 2 ) , => Array ( => 3 ) , => Array ( => 4 ) , => Array ( => 1 ) , => Array ( => 2 )...
8
by: SpreadTooThin | last post by:
Basically I think the problem is in converting from a 32 bit integer to a 16 bit integer. I have two arrays: import array a = array.array('L', ) b = array.array('H', ) b = a
2
by: arda | last post by:
how i can put 2d array to a pointer? In the below program i am giving a first value to output_bit and then start to a loop and putting the new values to an another array as called newdata. But as i...
2
by: Toni | last post by:
I have ImageButton array. I have defined onClick event and it works. But in this function I can not use control propetries. I want to use index of ImageButton which is clicked and ImageURL...
3
by: Robert Bevington | last post by:
Hi all, I ran into memory problems while tying to search and replace a very large text file. To solve this I break the file up into chunks and run the search and replace on each chunk. This...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.