-
Recent Posts
- Hwarang Spirit
- Alchemy
- ListView minHeight, typeface
- Clear All Lint Markers Errors
- android.permission.INTERNET
- eclipse Korean character problem
- OnItemCLickListener not working gridview
- G is G!
- Eclipse shortcut to comment selection in an XML file
- android.app.activitythread.performlaunchactivity nullpointerexception
- How to uninstall Windows Live Essentials via CMD line parameter
- vi fold method
- android.os.NetworkOnMainThreadException
- android socket
- socket2
Tags
Archives
Monthly Archives: August 2013
ListView minHeight, typeface
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:minHeight="45dip" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15sp" android:typeface="monospace" android:textSize="15sp" android:maxHeight="120dp" /> </LinearLayout> |
Posted in Android
Leave a comment
Clear All Lint Markers Errors
case of ”Clear All Lint Markers” error … open AndroidManifest.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="oh.my.girl" android:versionCode="1" android:versionName="1.0" > <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name="MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.INTERNET" /> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="9" /> </manifest> |
android.permission.INTERNET
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="oh.my.girl" android:versionCode="1" android:versionName="1.0" > <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name="MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.INTERNET" /> </manifest> |
Posted in Android
Leave a comment
eclipse Korean character problem
1 |
Window | Preferences | General | Workspace | Text file encoding | Other | UTF-8 |
OnItemCLickListener not working gridview
true -> false
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:orientation="vertical" android:padding="5dp" android:clickable="false" android:focusable="false" android:background="@drawable/grid_color_selector" > <TextView android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:gravity="center" android:textSize="12sp" > </TextView> </LinearLayout> |
http://stackoverflow.com/questions/5982472/gridview-onitemclicklistener-never-gets-invoked http://stackoverflow.com/questions/5577945/onitemclickevent-not-fired-in-gridview-in-android
android.app.activitythread.performlaunchactivity nullpointerexception
1 2 3 4 |
08-26 21:41:08.371: E/AndroidRuntime(17789): Caused by: java.lang.NullPointerException 08-26 21:41:08.371: E/AndroidRuntime(17789): at android.widget.ArrayAdapter.init(ArrayAdapter.java:310) 08-26 21:41:08.371: E/AndroidRuntime(17789): at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:153) 08-26 21:41:08.371: E/AndroidRuntime(17789): at oh.my.girl._GridViewAdapter.<init>(_GridViewAdapter.java:15) |
Posted in Android
Leave a comment
How to uninstall Windows Live Essentials via CMD line parameter
“c:\program files\windows live\installer\wlarp.exe” /cleanup:all /q http://answers.microsoft.com/en-us/windowslive/forum/messenger-wlinstall/how-to-uninstall-windows-live-essentials-via-cmd/3d26c7ea-faf0-437a-88b0-c5bdd3dd31ec
vi fold method
.vimrc configuration
1 2 3 4 5 6 7 8 9 10 |
setlocal foldmethod=expr setlocal foldexpr=(getline(v:lnum)=~'^$')?-1:((indent(v:lnum)<indent(v:lnum+1))?('>'.indent(v:lnum+1)):indent(v:lnum)) set foldtext=getline(v:foldstart) set fillchars=fold:\ "(there's a space after that \) highlight Folded ctermfg=DarkGreen ctermbg=Black nnoremap <S-Left> zo inoremap <S-Left> <C-O>zo nnoremap <S-Right> zc inoremap <S-Right> <C-O>zc |
vi command mode
1 |
:set foldmethod=indent |
zR -> unfold all zM -> fold all za -> fold/unfold
android.os.NetworkOnMainThreadException
android.os.NetworkOnMainThreadException -> execution error correct source(after)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
package oh.my.girl; import java.io.IOException; import java.io.ObjectOutputStream; import java.net.Socket; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class NetworkActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.control); ConnectThread(); } void ConnectThread() { new ConnectTask().execute(null,null,null); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
package oh.my.girl; import java.io.IOException; import android.os.AsyncTask; public class ConnectTask extends AsyncTask<Void, Void, Void> { String ip = "192.168.0.2"; int port = 8080; @Override protected Void doInBackground(Void... arg0) { // TODO Auto-generated method stub try { SocketClient sc = new SocketClient(ip, port); sc.createClientSocket(); } catch (IOException e) { } return null; } } |
wrong source (before)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
public class NetworkActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.control); try { SocketClient sc = new SocketClient(ip, port); sc.createClientSocket(); } catch (IOException e) { } } } |
impossible to connet network in main UI thread after Android 3.0 version so you must create other thread cite from -> http://ironheel.tistory.com/48 사실 위 코드에는 문제가 전혀 없다. 문제는 … Continue reading
Posted in Android
Leave a comment
android socket
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
package oh.my.girl import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.Socket; import android.app.Activity; import android.os.Bundle; import android.widget.Button; import android.widget.TextView; public class SocketClient extends Activity { Button button1; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String host = "192.168.0.2"; int port = 8080; Socket socket = null; OutputStream os = null; OutputStreamWriter osw = null; try { socket = new Socket(host, port); os = socket.getOutputStream(); osw = new OutputStreamWriter(os); } catch (IOException e) { } String message = "I love you"; try { osw.write(message, 0, message.length()); osw.flush(); } catch (IOException e) { } TextView tv = (TextView) findViewById(R.id.text); tv.setText(message); try { socket.close(); } catch (IOException e) { } } } |
socket2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
public static void main(String args[]) { String ip = "192.168.0.2"; int port = 8080; Socket socket = null; OutputStream os = null; OutputStreamWriter osw = null; Socket socket2 = new Socket(); SocketAddress sock_addr = new InetSocketAddress(ip, port); try { socket2.connect(sock_addr); } catch (UnknownHostException ue) { } catch (IOException ie) { } try { os = socket2.getOutputStream(); osw = new OutputStreamWriter(os); } catch (IOException ie) { } String data = "I love you"; try { osw.write(data, 0, data.length()); osw.flush(); } catch (IOException ie) { } } |
socket client data stream main
1 2 3 4 5 6 7 8 9 10 11 12 |
public static void main(String args[]) { String ip = "192.168.0.2"; int port = 8080; try { SocketClient sc = new SocketClient(ip, port); sc.createSocket("Welcome!"); } catch (IOException e) { } } |
Posted in Android, Java
Leave a comment
socket write OutputStreamWriter OutputStream getOutputStream
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public void createSocket(String str) { try { os = socket.getOutputStream(); osw = new OutputStreamWriter(os); } catch (IOException e) { } try { osw.write(str, 0, str.length()); osw.flush(); } catch (IOException e) { } } |
Posted in Android, Java
Leave a comment
SocketClient constructor
1 2 3 4 5 6 7 |
SocketClient(String ip, int port) throws IOException { try { socket = new Socket(ip, port); } catch (IOException e) { throw e; } } |
Posted in Uncategorized
Leave a comment
Create a Project with Command Line
1 2 3 |
android create project --target 13 --name XXX --path ./Desktop/XXX --activity XXXActivity --package com.XXX |
http://developer.android.com/training/basics/firstapp/creating-project.html#CommandLine
Java Source Structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
// =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== // =========================================================== // Inner and Anonymous Classes // =========================================================== |
java int to string
1 2 3 |
int n = 1; String str = String.valueOf(n); |
Eclipse shortcut to comment selection in an XML file
Comment/Uncomment toggle -> Ctrl+Shift+C
http://stackoverflow.com/questions/3025546/eclipse-shortcut-to-comment-selection-in-an-xml-file