이 블로그 검색

2011년 5월 29일 일요일

세로로 스크롤 되는 텍스트 뷰 만들기

안드로이드 ... 가끔 이해 안되는 구석이 많다... ;;
꼭 아래와 같이 해야 되더라... ;;

<ScrollView android:id="@+id/scrollView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">   
<TextView
 android:id="@+id/subtitle"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />          
</ScrollView>

요렇게 해도 되긴 되네..
<ScrollView android:id="@+id/scrollView"
   android:layout_width="295dip"
   android:layout_height="390dip"
   android:background="@drawable/text_field_b_sel"
   android:layout_gravity="center_horizontal" 
>
<LinearLayout 
android:layout_height="wrap_content"
android:layout_width="wrap_content"
>
<TextView android:text="" 
android:layout_width="295dip"
android:layout_height="wrap_content"
android:id="@+id/textContent" 
android:paddingLeft="3.5dip"
   style="@style/color1_2_size16" android:layout_gravity="fill_vertical|center_horizontal"  >
</TextView>
</LinearLayout>
</ScrollView>

2011년 5월 24일 화요일

Android Activity 생명 주기에 대한 확실한 이해

http://eddykudo.com/63

여기 자세히 나와 있음.. ㅎㅎ

android.text.Html - 문자열에 색깔, 폰트, 밑줄 등을 변경 할 때

* 문자열에 색깔이나 폰트, 밑줄 등의 변경을 주고자 할 때,

android.text.Html 을 이용한다.

String s1 = s1 +"<font color=\"#ff8c00\">"+sortMinArr.get(i).substring(0, 2)+"&nbsp</font>"

위의 주황색처럼 HTML 형식으로 쓰고, 

Html.fromHtml(s1);  // -> s1을 나중에 Html.fromHtml로 감싸면 된다.

2011년 5월 6일 금요일

getView()를 다시 그리고 싶을때,

notifyDataSetChange : 변경된 View를 다시 그린다.
커스텀 리스트뷰에서 getView()를 재호출한다. !!

2011년 4월 26일 화요일

커스텀 뷰 만들시 커스텀어댑터에서 implement 되는 모든 메서드를 정확히 구현해야 한다.

 class CustomerAdapter extends BaseAdapter{
   
     Context maincon;
     LayoutInflater Inflater;
     ArrayList<Customer> vSource;
     int tlayout;
     
     CustomerAdapter(Context context, int targetLayout, ArrayList<Customer> sourceArr)
     {
      Log.i("Gilrs getneration", "서현" );
      maincon = context;
      Inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      vSource = sourceArr;
      tlayout = targetLayout;
     }
   
  @Override
  public int getCount() {
   // TODO Auto-generated method stub
   return  vSource.size();
  }
  @Override
  public Object getItem(int position) {
   // TODO Auto-generated method stub
   return vSource.get(position).cusName;
  }

  @Override
  public long getItemId(int position) {
   // TODO Auto-generated method stub
   return position;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
   // TODO Auto-generated method stub
  
   Log.i("Gilrs getneration", "태연" );
   final int pos = position;
  
   if(convertView == null)
   {
    convertView = Inflater.inflate(tlayout,parent, false);
    Log.i("Gilrs getneration", "윤아" );
   }
  
   TextView txt = (TextView)convertView.findViewById(R.id.listcon);
   txt.setText(vSource.get(position).cusName);
  
   convertView.setOnClickListener(new View.OnClickListener() {
   
    @Override
    public void onClick(View v) {
     // TODO Auto-generated method stub
    
    }
   });
   return convertView;
  }

2011년 4월 14일 목요일

Second topic was so interesting since I've had a lot of interesting about evil of human. This topic was so familiar with me.
Series killer, psychopath, homicide, massacre and raping .... the dark and basic human instinct which is related to violence and cruelty. I don't know since when I began to realize that human beings are basically evil and selfish. From that time I gave up trusting and giving expectation to people. This makes me easy because no expectation brings no disappointment. Even no surprising to me seeing evil like Kim jung-il's  on North Korea. 

2011년 3월 20일 일요일

일반 Server 통신과 AIDL을 이용한 방식

* 사실 일반 Server-Client 통신에서는 아래와 같은 문장만 있으면 Server에서 내려준 정보를 받기에 충분하다.

HttpClient mHttpClient = null;
String response;
String strUrl = "http://220.103.225.114:8083/search/getAddr.do?userid=1300072071621&sk=1bfd94bd74ef0b9f8305af5b21e79892&addr_mode=S&cnt_yn=Y";

 class TransThread extends Thread{   //Key
  public void run(){
   Log.e("", "run");

   response = null;

   try{
    Log.e("", "try");

   /* Server 통신 하는 부분 Start */
   URI uri = new URI(strUrl);  

    HttpGet request = new HttpGet();    // request 서버 접속 요청  
    request.setURI(uri);  

    HttpResponse httpResponse = mHttpClient.execute(request);  
   // HttpClient 형 객체 mHttpClient - Server에서 전송하는 Data가 담긴다. 
   response = EntityUtils.toString(httpResponse.getEntity()).trim(); 
  // String 형 객체 response에 server에서 날려준 정보를 Entity별로 담는다.
    Log.e("", "response" + response);

    messageProc(response); //  --> Jason Parser    }catch(Exception e){
    Log.e("", "catch");
    e.printStackTrace();
   }
  }
 }

위의 Server 통신 부분을 Thread에 넣고 안드로이드 Service를 호출해서 받는다.

public void startTransaction(HttpClient mHttpClient, Context ctx, String url, String params){
  if(readyTransaction(ctx)){
   //readyTransaction에서 true가 떨어졌을 경우
   strUrl = url;
   strParams = params;

   this.mHttpClient = mHttpClient;
   if(this.mHttpClient != null){

   }
   worker = new TransThread();   // Thread 생성
   worker.start();    // Thread 시작
  }
 }

 public void doGetUpgrade() throws RemoteException {
   // TODO Auto-generated method stub
   TestSource ts = new TestSource(getApplicationContext());
   ts.startTransaction(mHttpClient, getApplicationContext());   //startTransaction 호출
}


/*  ServiceConnection 객체 생성 Start*/
 ServiceConnection srvConn = new ServiceConnection() {  

  @Override
  public void onServiceDisconnected(ComponentName name) {
   // TODO Auto-generated method stub
   updateService = null;
  }

  @Override
  public void onServiceConnected(ComponentName name, IBinder service) {   // 요 녀석이네...
   // TODO Auto-generated method stub
   updateService = IService.Stub.asInterface(service);     // 이부분이 AIDL 을 처리하는 부분
   Log.e("", "service");
   if(updateService!=null){
    try{
     updateService.doGetUpgrade();   //doGetUpgrade 호출 
     }catch(Exception e){
     e.printStackTrace();
    }
   }
  }
 };

/* ServiceConnection 객체 생성 End */

/* onResume  Start */
 protected void onResume() {
 super.onResume();

  Intent intent = new Intent("kr.softcast.Metroi.Service.StationService.ACTION");
  this.bindService(intent, srvConn, Context.BIND_AUTO_CREATE); 
   // bindService에서 srvConn 호출  --> 원격 호출 Service (IPC)
}


/*** Jason Parsing 부분 ***/
void messageProc(String response) {
  // TODO Auto-generated method stub
  Log.e("", "messageProc");
 
  this.response = response;
  getResult(response.trim()); 
 }
 boolean bSuccess;
 ArrayList<Station> stationList = new ArrayList<Station>();
  //JSON object parse
 private void getResult(String response){  
   //파씽 - 이미 string 형태로 받아온 response를 Jason으로 다시 파씽
  Log.e("getresult", response);
  JSONObject jsonObj = null;
  JSONArray jsonArr = null;
  try{
   jsonObj = ServerUtils.parserMSG(response);
  }catch(Exception e){
   e.printStackTrace();
  }
 
  try{
   bSuccess = jsonObj.getBoolean("success");
  }catch(Exception e){
   e.printStackTrace();
  }
 
  try{
   if(!bSuccess){ //false
   
   }else{
   
   }
  }catch(Exception e){
  
  }
 }

//* JSONObject *//

import org.json.JSONException;
import org.json.JSONObject;
public class ServerUtils {
 // json object
 public static JSONObject parserMSG(String msg) {
  JSONObject jObj = null;
  try {
   jObj = new JSONObject(msg.trim());  // 생성자 인자에 때려 넣으면 자동으로 파씽되나 보네...
  } catch (JSONException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   return null;
  }
  return jObj;
 }
}