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,
     Dileep

--



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 http://developer.android.com/guide/developing/device.html 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?

hi,all:

  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
listview.
  the code as follows:
package miaozl.hello;

import android.app.ListActivity;
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. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mDbHelper = new helloAdapter(this);
        mDbHelper.open();
        mFactory = LayoutInflater.from(this);
        lv= getListView();
        lv.setChoiceMode(1);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener(){

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

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

        String[] from = new String[] {
helloAdapter.KEY_WORD,helloAdapter.KEY_ID};
        int[] to = new int[] { R.id.word,R.id.button};
        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
        }

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

                @Override
                public void onClick(View arg0) {
                    // TODO Auto-generated method stub
                    Log.d(TAG,
"=cursor.getPosition()="+cursor.getPosition());
                }
            });

        }

        @Override
        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(R.id.word);
            Button onButton=(Button)ret.findViewById(R.id.button);
            onButton.setFocusable(false);

word.setText(cursor.getString(cursor.getColumnIndex(helloAdapter.KEY_WORD)));
            onButton.setBackgroundResource(R.drawable.icon);
            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);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {

            db.execSQL(DATABASE_CREATE);
        }

        @Override
        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");
            onCreate(db);
        }
    }

    /**
     * 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
to
     * 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
created
     */
    public helloAdapter open() throws SQLException {
        mDbHelper = new DatabaseHelper(mCtx);
        mDb = mDbHelper.getWritableDatabase();
        return this;
    }

    public void close() {
        mDbHelper.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
return
     * 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) {
            mCursor.moveToFirst();
        }
        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
body
     * 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="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal"
      android:layout_width="wrap_content"
    android:layout_height="wrap_content">
      <TextView android:id="@+id/word"
        android:layout_width="250dip"
        android:layout_height="wrap_content"/>
    <Button android:id ="@+id/button"
        android:layout_width ="50dip"
        android:layout_height ="wrap_content"/>
</LinearLayout>


pls help me /*******************************************/
Miao Zhong-liang)
MSN:mzl...@163.com <msn%3amzl...@163.com>
BLOG:http://miaozl.spaces.live.com
/*******************************************/

-- 

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