d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Android Help! > Please!
Add Reply New Topic New Poll
Member
Posts: 15,666
Joined: Jul 15 2007
Gold: 3,046.40
Jun 18 2012 06:48pm
How do I create an activity after an item is clicked on my list view?

Basically, what to do if I want (for example) a new layout.xml file to open?


Code
listView1.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {
                   switch(position){
            case 0: Intent newActivity = new Intent(SecretBurgersActivity.this, BurgerItems.class);
              startActivity(newActivity);
              break;
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 18 2012 06:56pm
that looks correct. what's the problem?

/edit: did you add that activity to your manifest?

This post was edited by carteblanche on Jun 18 2012 06:56pm
Member
Posts: 15,666
Joined: Jul 15 2007
Gold: 3,046.40
Jun 18 2012 07:01pm
Quote (carteblanche @ Jun 18 2012 04:56pm)
that looks correct. what's the problem?

/edit: did you add that activity to your manifest?



I did?

edit: Am I supposed to put a listener into the BurgerItems.java?

Code
<activity
           android:name=".SecretBurgersActivity"
           android:label="@string/app_name" >
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />

               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>
       
       
                   <activity
           android:name=".BurgerItems"
           android:label="@string/app_name" >
                       <intent-filter>
               <action android:name="boxed.goods.secretburgers.BURGERITEMS" />

               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>


This post was edited by Calamitymic on Jun 18 2012 07:01pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 18 2012 07:21pm
can you take a step back and explain what isn't working?

1. is your onclick listener called?
2. is the case 0 executed?
3. is there an exception?

add logging or debug if you dont know the answers to #1/2
Member
Posts: 15,666
Joined: Jul 15 2007
Gold: 3,046.40
Jun 18 2012 07:29pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 18 2012 07:34pm
Quote
06-18 22:33:48.326: E/AndroidRuntime(1607): Caused by: java.lang.OutOfMemoryError
06-18 22:33:48.326: E/AndroidRuntime(1607):    at android.graphics.Bitmap.nativeCreate(Native Method)


do you have some really large bitmap? if you manually load this activity as your startup, does it load successfully? if this is on the emulator, increase your memory

certain files are compressed into the apk file, then get decompressed in memory during runtime (which could cause out of memory issues). if this is one of those cases, you have to set it to not compress and just use the raw file
Member
Posts: 15,666
Joined: Jul 15 2007
Gold: 3,046.40
Jun 18 2012 07:48pm
http://pastebin.com/uvHXXMQ9

resized the background for the layout i wanted to use and got this error now.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 18 2012 07:52pm
Quote
06-19 01:45:31.742: E/AndroidRuntime(1441): FATAL EXCEPTION: main
06-19 01:45:31.742: E/AndroidRuntime(1441): android.app.SuperNotCalledException: Activity {boxed.goods.secretburgers/boxed.goods.secretburgers.BurgerItems} did not call through to super.onCreate()


seriously man, you gotta learn how to read your errors

This post was edited by carteblanche on Jun 18 2012 08:09pm
Member
Posts: 15,666
Joined: Jul 15 2007
Gold: 3,046.40
Jul 12 2012 07:58pm
Code

///Menu button
       bStyle.setOnClickListener(new View.OnClickListener() {

  public void onClick(View v) {
   // TODO Auto-generated method stub
   
       //////////////What's the code to open an image from drawable folder? ///////////////////////////////
                               
  }
 });
///
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll