problem in adding animation to imageview

by uru » Tue, 01 Jul 2008 14:07:08 GMT


Sponsored Links
 package com.android.Riverchk;



import android.app.Activity;

import android.os.Bundle;
import android.view.animation.TranslateAnimation;

import android.widget.ImageView;

public class checkr extends Activity {


    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        ImageView i1;
        i1=(ImageView)findViewById(R.id.i1);
        i1.setImageResource(R.drawable.flower);
        setContentView(R.layout.main);
        TranslateAnimation trans1 = new TranslateAnimation(0, 30, 0,
0);
        trans1.setStartOffset(0);
        trans1.setDuration(800);
        trans1.setFillAfter(true);
        i1.startAnimation(trans1);

    }
}




this code gives nullpointerexception

--~--~---------~--~----~------------~-------~--~----~



problem in adding animation to imageview

by Mark Murphy » Tue, 01 Jul 2008 15:18:13 GMT


 > this code gives nullpointerexception

Move your setContentView() statement to be just under the super.onCreate()
statement.

You are attempting to find a widget (findViewById()) before the widget
exists (setContentView()).

If that does not help, could you let us know what line is causing the
exception?

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ -- Available Now!


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


problem in adding animation to imageview

by uru » Fri, 04 Jul 2008 20:25:40 GMT


 thanksss it works.........




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. parallel port driver of linux x86

hi,

  I have written a parallel port driver of linux x86 and i am not able
to generate the interrupt.could some one help me with this code please

I am enabling the interrupt in parallel_init() and the handler is in
parallel_hand.

pls help!!!I am trying to get this work

#include<linux/kernel.h>
#include<linux/init.h>
#include<linux/module.h>
#include<linux/fs.h>
#include<linux/cdev.h>
#include<linux/slab.h>
#include<linux/device.h>
#include<linux/ioport.h>
#include<asm/io.h>
#include<asm/uaccess.h>
#include<linux/delay.h>

#include<linux/interrupt.h>

#define  DRIVER_NAME "PARALLEL_PORT_DRIVER"
#define DEVICE_NAME "PARALLEL_PORT"
#define CLASS_NAME "PARALLEL_CLASS"

MODULE_LICENSE("GPL");

static ssize_t  parallel_read(struct file *,char __user
*,size_t,loff_t *);
static ssize_t parallel_write(struct file *,const char __user
*,size_t,loff_t *);
static int parallel_open(struct inode *,struct file *);


struct class *device_class=NULL;
//static dev_t dev;
static LIST_HEAD(char_dev_list);

struct file_operations fops =
{
                .owner=THIS_MODULE,
                .read=parallel_read,
                .write=parallel_write,
                .open=parallel_open
};

irqreturn_t parallel_hand(int irq_no,void * dev)
{
        printk(KERN_ALERT"interrupt received\n");
        return 0;
}

struct paralleldriver
{
        u8 data;
        unsigned long addr;
        void * paddr;
        struct list_head list;
        struct cdev parallel_cdev;
        dev_t dev;
};

static ssize_t parallel_read(struct file * flip,char __user *
buff,size_t length,loff_t * off_t)

{
        return 0;
}


static ssize_t parallel_write(struct file * flip,const char __user*
buff,size_t length,loff_t * off_t)

{
        printk(KERN_ALERT "in write");
        struct paralleldriver *driver;
        driver=flip->private_data;
        copy_from_user((void*)&driver->data,(const void __user *)buff,1);
        printk(KERN_ALERT "%c",*buff);
        printk(KERN_ALERT "%c",driver->data);
        outb(driver->data,driver->addr);
        mdelay(1);
        return 1;
}

static int parallel_open (struct  inode * inode,struct file * flip)
{
        printk(KERN_ALERT "in open\n");
        struct paralleldriver * driver=NULL;
        driver=container_of(inode->i_cdev,struct
paralleldriver,parallel_cdev);
        flip->private_data=driver;
        driver->addr=0x0378;
        return 0;
}


static int parallel_init (void);
static void parallel_exit (void);

static int parallel_init(void)
{
        struct paralleldriver *driver=NULL;
        struct device *device=NULL;
        unsigned long addr=0x0378;

        driver=kmalloc(sizeof(struct paralleldriver),GFP_KERNEL);
        driver->addr=addr;
//driver register
        alloc_chrdev_region(&driver->dev,0,5,DRIVER_NAME);

        list_add_tail(&driver->list,&char_dev_list);

//device register
        cdev_init(&(driver->parallel_cdev),&fops);

        driver->parallel_cdev.owner=THIS_MODULE;
        if(cdev_add(&(driver->parallel_cdev),driver->dev,5) < 0)
        {
                printk(KERN_ALERT "FAILED TO INSERT");
                return 1;
        }

//creating a device
        device_class=class_create(THIS_MODULE,CLASS_NAME);
        device=device_create(device_class,NULL,driver-



//allocating memory regions
        request_mem_region((unsigned long)driver->addr,
1,"PARALLEL_PORT_REGION");


request_irq(7,parallel_hand,0,"start_motor_handler",(void *)driver);
//enabling interuppt
        addr=0x0378;
        outb(16,addr+2);


//pin4 of parallel port is directly connected to pin 10 through a wire
//enabling pin4 high to enable interrupt

        outb(255,addr);
        mdelay(1);
        outb(0,addr);
        mdelay(1);
        outb(255,addr);
        mdelay(1);
        printk(KERN_ALERT "inserted");

return 0;


}

static void parallel_exit(void)
{
        struct paralleldriver *first,*next;
        list_for_each_entry_safe(first,next,&char_dev_list,list)
        {
                release_mem_region(first->addr,1);
                device_destroy(device_class,first->dev);
                class_destroy(device_class);
                unregister_chrdev_region(0,5);
                kfree(first);
                printk(KERN_INFO "EXITED");
        }
}


module_init(parallel_init);
module_exit(parallel_exit);


regards,
ajay

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

2. how to release Paid upgrade for Free app?

Hi,

Is there a way to change free app into paid app in Market? I.e. you
release com.foo.xxx as free but later
you'd like to charge for app and drop free version completely.. I do
not see anything like this in Market console
at the moment. I know I can release com.foo.xxx.pro for example but my
intention would be to keep
package name as is so current users would see there's upgrade
available. Alternatively, if there's no
way to do that can I completely remove app from market so com.foo.xxx
would be resuable for other
app?

-- 

3. How to pass objects around activities using "A HashMap of WeakReferences to Objects"?

4. trying to open new image on clicking a image button

5. changing values inside a layout included with include.

6. Cordinates provided by geo fix command to emulator are different in location listener

7. Query about SlideShow Implementation.