and then Hwarang Spirit
At last you will win…
and then Hwarang Spirit
At last you will win…
“And, when you want something, all the universe conspires in helping you to achieve it.”
http://www.goodreads.com/work/quotes/4835472-o-alquimista
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> |
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> |
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> |
1 |
Window | Preferences | General | Workspace | Text file encoding | Other | UTF-8 |
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
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) |
“c:\program files\windows live\installer\wlarp.exe” /cleanup:all /q
.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 -> 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
사실 위 코드에는 문제가 전혀 없다.
문제는 android가 변했다는 점이다.
결론부터 말하자면 honeycomb에서는 main thread(UI)에서 네트워크 호출을 하면 무조건 error로 간주한다.
앱 전체의 thread와 컨트롤을 관리하는 main에서 네트워크 호출로 대기중인 시간이 길어지면
사용자는 안드로이드앱의 문제로 인식하게 된다. 이를 방지하자는 것이 목적이다.
다음 링크를 참조하자 : painless threading 번역글
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) { } } } |
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) { } } |
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) { } } |
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) { } } |
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; } } |
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
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