Tag Archives: Android_java

Android: make TextView looks exactly like EditText

android:background=”?attr/editTextBackground”

  <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Your text"
            android:hint="My hint"
            android:textColor="?attr/editTextColor"
            android:background="?attr/editTextBackground"
            android:gravity="center_vertical"
            android:textAppearance="?android:attr/textAppearanceMediumInverse"
            />

Enable NDK debug on Eclipse , Ubuntu

Summary

  • Push compiled binary to phone via adb push
    push gdb server to phone
    on phone: run gdb server with given TCP port

    on unbuntu: set TCP port forwarding
    on eclipse: set debug configuration to use TCP connection.

  • Details:

  • Push compiled binary to phone via adb push
    push gdb server to phone
    adb shell push $ANDROID_NDK_ROOT/prebuilt/android-arm/gdbserver/gdbserver /data
    Push compiled binary to phone via adb push

    adb push /home/victor/workspace/xxx/obj/local/armeabi/testPcap /data/app
    on phone: run gdb server with given TCP port
    adb shell
    On phone: /data/gdbserver :5039 /data/app/testPcap

    on unbuntu: set TCP port forwarding 在本地把本地TCP端口forward到设备的TCP端口

    adb forward tcp:5039 tcp:5039

    on eclipse: set debug configuration to use TCP connection.


  • Eclipse 设置调试
    程序为 /home/victor/workspace/xxx/obj/local/armeabi/testPcap
    DEBUGER: gdbserver

    gdb debuger: /home/victor/dev/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb
    gdb commandline: /home/victor/workspace/xxxx/libs/armeabi/droidsheep
    Connection localhost 5039

    enable checkbox events in Listview

    listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view,
    int position, long id) {
    // When clicked, show a toast with the TextView text
    Country country = (Country) parent.getItemAtPosition(position);
    CheckBox cb=(CheckBox)view.findViewById(R.id.checkBox1);
    cb.toggle();
    country.setSelected(cb.isChecked());
    Toast.makeText(getApplicationContext(),
    “Clicked on Row: ” + country.getName(),
    Toast.LENGTH_LONG).show();
    }
    });

     

    http://developer.android.com/reference/android/widget/Checkable.html#toggle()