Regarding Rotation event

by Dilip Dilip » Tue, 09 Mar 2010 23:28:09 GMT

Sponsored Links
 Hi All,
  is there any way i can recieve rotation event(change in orientation)  in
my .cpp file.

Thanks and Regards,


Other Threads

1. Need help setting up my device for development

The following works for me:

adb kill-server
sudo ./adb start-server
adb devices

Hi, I'm developing an Android app using Eclipse on Debian Lenny, and I'd like to test it on my HTC Magic. I followed the instructions given in for Ubuntu Gusty/Hardy, but the device does not seem to be set up properly: x...@xxx:~/android-sdk-linux_86/tools$ ./adb devices List of devices attached ???????????? no permissions Are these instructions supposed to work also with Debian Lenny or is there anything more to do? Thank you Julien

2. how to deal with button clickevent in a listview?


  I write a listactivty,the item including a textview and a buttonhe data
came from a sqliteut in handling the clickevent , i meet some problem, in
the CursorAdapter's bindView() function cann't get the current positionn
log find position of Cursor is the position I last click the item of
  the code as follows:
package miaozl.hello;

import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CursorAdapter;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

public class helloActivity extends ListActivity{
    private helloAdapter mDbHelper;
    private final static String TAG ="helloActivity";
    private static LayoutInflater mFactory;
    ListView lv;
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        mDbHelper = new helloAdapter(this);;
        mFactory = LayoutInflater.from(this);
        lv= getListView();
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener(){

            public void onItemClick(AdapterView<?> arg0, View arg1, int
                    long arg3) {
                // TODO Auto-generated method stub
                Log.d(TAG,"====onItemClick===arg3 is ==="+arg3);

    private void fillData() {
        // TODO Auto-generated method stub
        Cursor c = mDbHelper.fetchAllNotes();

        String[] from = new String[] {
        int[] to = new int[] {,};
        lv.setAdapter(new ListAdapter(this, c));
    private static class ListAdapter extends CursorAdapter {

        public ListAdapter(Context context, Cursor c) {
            super(context, c);
            // TODO Auto-generated constructor stub

        public void bindView(View view, Context context, final Cursor
cursor) {
            // TODO Auto-generated method stub
            Button onButton=(Button)view.findViewById(;
            onButton.setOnClickListener(new OnClickListener(){

                public void onClick(View arg0) {
                    // TODO Auto-generated method stub


        public View newView(Context context, Cursor cursor, ViewGroup
parent) {
            // TODO Auto-generated method stub
            View ret= mFactory.inflate(R.layout.list_item,parent,false);
            TextView word=(TextView)ret.findViewById(;
            Button onButton=(Button)ret.findViewById(;

            return ret;


 the ListAdapter as fallows:

package miaozl.hello;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class helloAdapter{
    public static final String KEY_WORD = "word";
    public static final String KEY_ID = "_id";
    private static final String TAG = "helloAdapter";
    private DatabaseHelper mDbHelper;
    private SQLiteDatabase mDb;

    private static final String DATABASE_CREATE =
        "create table notes (_id integer primary key autoincrement, "
        + "word text not null);";
    private static final String DATABASE_NAME = "list";
    private static final String DATABASE_TABLE = "notes";
    private static final int DATABASE_VERSION = 1;
    private final Context mCtx;
    private static class DatabaseHelper extends SQLiteOpenHelper {

        DatabaseHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);

        public void onCreate(SQLiteDatabase db) {


        public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
            Log.w(TAG, "Upgrading database from version " + oldVersion + "
to "
                    + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS notes");

     * Constructor - takes the context to allow the database to be
     * opened/created
     * @param ctx the Context within which to work
    public helloAdapter(Context ctx) {
        this.mCtx = ctx;

     * Open the notes database. If it cannot be opened, try to create a new
     * instance of the database. If it cannot be created, throw an exception
     * signal the failure
     * @return this (self reference, allowing this to be chained in an
     *         initialization call)
     * @throws SQLException if the database could be neither opened or
    public helloAdapter open() throws SQLException {
        mDbHelper = new DatabaseHelper(mCtx);
        mDb = mDbHelper.getWritableDatabase();
        return this;

    public void close() {

     * Create a new note using the title and body provided. If the note is
     * successfully created return the new rowId for that note, otherwise
     * a -1 to indicate failure.
     * @param title the title of the note
     * @param body the body of the note
     * @return rowId or -1 if failed
    public long createNote(String word) {
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_WORD, word);

        return mDb.insert(DATABASE_TABLE, null, initialValues);

     * Delete the note with the given rowId
     * @param rowId id of note to delete
     * @return true if deleted, false otherwise
    public boolean deleteNote(long rowId) {

        return mDb.delete(DATABASE_TABLE, KEY_ID + "=" + rowId, null) > 0;

     * Return a Cursor over the list of all notes in the database
     * @return Cursor over all notes
    public Cursor fetchAllNotes() {

        return mDb.query(DATABASE_TABLE, new String[] {KEY_ID, KEY_WORD
                }, null, null, null, null, null);

     * Return a Cursor positioned at the note that matches the given rowId
     * @param rowId id of note to retrieve
     * @return Cursor positioned to matching note, if found
     * @throws SQLException if note could not be found/retrieved
    public Cursor fetchNote(long rowId) throws SQLException {

        Cursor mCursor =

            mDb.query(true, DATABASE_TABLE, new String[] {KEY_ID,
                    KEY_WORD}, KEY_ID + "=" + rowId, null,
                    null, null, null, null);
        if (mCursor != null) {
        return mCursor;


     * Update the note using the details provided. The note to be updated is
     * specified using the rowId, and it is altered to use the title and
     * values passed in
     * @param rowId id of note to update
     * @param title value to set note title to
     * @param body value to set note body to
     * @return true if the note was successfully updated, false otherwise
    public boolean updateNote(long rowId,String word) {
        ContentValues args = new ContentValues();
        args.put(KEY_WORD, word);

        return mDb.update(DATABASE_TABLE, args, KEY_ID + "=" + rowId, null)

list_item.xml as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
      <TextView android:id="@+id/word"
    <Button android:id ="@+id/button"
        android:layout_width ="50dip"
        android:layout_height ="wrap_content"/>

pls help me /*******************************************/
Miao Zhong-liang) <>


3. Tabacitivty

4. newbie mau nanya ttg psr ml

5. Mirink Springhill updated

6. Need help setting up my device for development

7. Reminder, Miring @ Spring Hills, Kemayoran