programing2012. 11. 23. 17:46
SMS
 
private void SendSMS(String phonenumber, String message) {
		SmsManager smsManager = SmsManager.getDefault();
		String sendTo = phonenumber;
		String myMessage = message;
		smsManager.sendTextMessage(sendTo, null, myMessage, null, null);
		Toast.makeText(SMSSender.this, "전송되었습니다.", Toast.LENGTH_SHORT).show();
		finish();
	}
MMS
	private void SendSMS(String phonenumber, String message) {
		SmsManager smsManager = SmsManager.getDefault();
		String sendTo = phonenumber;
		ArrayList partMessage = smsManager.divideMessage(message);
		smsManager.sendMultipartTextMessage(sendTo, null, partMessage, null, null);
		Toast.makeText(SMSSender.this, "전송되었습니다.", Toast.LENGTH_SHORT).show();
		finish();
	}
SMS
플랫폼에서 제공하는SMS로 떠넘기기..
	private void SendSMS(String phonenumber, String message) {
		Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + phonenumber));
		intent.putExtra("sms_body", message);
		startActivity(intent);
		finish();
	}

마지막에 플랫폼에서 제공하는걸로하니까 겔럭시 시리즈에서 전화번호를 못넘기는 현상이있다...
테스트해본폰은 겔럭시U,겔럭시S2 HD, 겔럭시3.... 겔럭시S2 HD에서는 전화번호를 못넘기는현상이있었다...

Posted by 부르마
programing2012. 11. 23. 17:28
로딩화면 그냥 보여주는건 누구나할수있는데 내가 원하는타이밍에 마춰하는건 쉽지 않습니다.? 나한테만 어려울수도...
아래 참고하면 도움이 될수있습니다.

호출부 인자값은 정해주기 나름이며 처리부 protected Void doInBackground(String... urls)
urls에 하나씩 매칭이됩니다. urls[0],urls[1]....이런식이죠...

 
//호출부...
 new PutLocation().execute("1", uniqueId, "00000");

 //서버에 값을 전송하고 정상적으로 처리될때까지 로딩화면을 보여준다.
 //정상적으로 처리가안될경우에 response값을 비교하여 에러처리를 한다.
 //처리부...
 protected class PutLocation extends AsyncTask {  //이거 이상하네요.. 알아서..들....
  private String Error = null;
  private Dialog Dialog = new Dialog(Location.this, R.style.ProgressDialog);
  HttpResponse response;
  
  // - 결과값 받기전까지 보여줄 메시지
  protected void onPreExecute() {
   Dialog.setContentView(R.layout.progressbar);
   Dialog.show(); // 로딩 시작
  }

  // - 결과값 받기
  protected Void doInBackground(String... urls) {
   StringBuffer buffer = new StringBuffer();
   try {
    buffer.append("platformId").append("=").append(urls[0]).append("&");
    buffer.append("uniqueId").append("=").append(urls[1]).append("&");
    buffer.append("locationId").append("=").append(urls[2]);
    HttpGet get = new HttpGet("URL");

    HttpClient client = new DefaultHttpClient();

    response = client.execute(get);

   } catch (ClientProtocolException e) {
    Error = "ClientProtocolException";
    cancel(true);
   } catch (IOException e) {
    Error = "IOException";
    cancel(true);
   } catch (Exception e) {
    Error = "Exception";
    cancel(true);
   }

   //return을 처리하면 onPostExecute에서 return값을 받아 결과값을 처리할수있다.
   return null;
  }

  // 결과값 처리
  protected void onPostExecute(Void unused) {
   Dialog.dismiss(); // 로딩종료
  }
 }
Posted by 부르마
programing2012. 8. 14. 17:36

TestListActivity.java

TestListAdapter mCustomAdapter;

mCustomAdapter = new TestListAdapter(TestNews.this, lDataList, R.layout.test_datalist, from, to);
mLv_TestList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
mLv_TestList.setAdapter(mCustomAdapter);

TestListAdapter.java

public class TestListAdapter extends SimpleAdapter {

	private List<Map<String, String>> mArrayList;
	private int mResource; // Layout ID
	private Context mContext;
	ViewHolder holder;
	ArrayList<Boolean> array;

	public TestListAdapter(Context context, List<Map<String, String>> lDataListFix, int resource, String[] from, int[] to) {
		super(context, lDataListFix, resource, from, to);
		mArrayList = lDataListFix;
		mResource = resource;
		mContext = context;

	}

	@Override
	public int getCount() {
		return mArrayList.size();
	}

	@Override
	public Object getItem(int position) {
		return mArrayList.get(position).get("msg") + "<" + mArrayList.get(position).get("date") + ">";
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = vi.inflate(mResource, null);

			holder = new ViewHolder();
			holder.msg = (TextView) convertView.findViewById(R.id.msg);
			holder.date = (TextView) convertView.findViewById(R.id.date);
			holder.cb_checkbox = (CheckBox) convertView.findViewById(R.id.cb_checkbox);
			convertView.setTag(holder);
		} else
			holder = (ViewHolder) convertView.getTag();

		Map<String, String> iItem = mArrayList.get(position);

		holder.tv_Msg.setText(iItem.get("msg"));
		holder.tv_CreateDate.setText(iItem.get("date"));
		holder.cb_checkbox.setChecked(false);

		holder.cb_checkbox.setChecked(((ListView)parent).isItemChecked(position));
		return convertView;
	}

}

class ViewHolder {
	TextView msg;
	TextView date;
	CheckBox cb_checkbox;
}


여기까지 별반 다르지 않았다. 체크박스 까지는 무난하게 만들지만 리스트가 늘어나면 문제가 생겼다.
체크하지 않았는데도 체크가되거나 스크롤 내리면 체크한 리스트에서 체크가 해제되어 보여졌다.
실제로는 체크가되어있었다.
인터넷에 많이 찾아봤지만 명쾌한 답이잘 없다. 결국 해결한건
holder.cb_checkbox.setChecked(((ListView)parent).isItemChecked(position));
한줄이다.

 TestListActivity.xml

<?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:orientation="horizontal" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/msg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:textColor="@color/black"
            android:textSize="17dp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/date"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:textColor="@color/text3" />
    </LinearLayout>

    <CheckBox
        android:id="@+id/cb_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp" 
        android:focusable="false"
        android:clickable="false"/>

</LinearLayout>
Posted by 부르마
programing2012. 8. 9. 17:32

일반적으로 커스트마이징 해서 글자색 변경하는 방법은 예제도 많고 쉽게 하고있다.

헌데.. ArrayAdapter를 써서 기본적으로 책에 나와있는 리스트를 만들면

기본적으로는 글자색 변경 폰트사이즈변경이 쉽지 않다..

모르는사람들을 위해서 삽질 좀덜하고자해서 쓴거니 필요없는사람은 백스페이스 다다다....

쉽게 하는방법 :

     mAdapter = new ArrayAdapter<String>(this,R.layout.simple_list_item_single_choice, titles);
     list = (ListView) findViewById(R.id.list);
     list.setAdapter(mAdapter);
     list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
     list.setOnItemClickListener(mItemClickListener);


▶  빨간색부분... 원래 코드는 android.R.layout.simple_list_item_single_choice 이다.

안드로이드 sdk 설치된 폴더에보면 simple_list_item_single_choice.xml 파일이있다 (다른 리스트도 동일하다.)

이 파일을 복사해서 내 프로젝트 layout폴더에 넣어준다.

그다음 R.layout.simple_list_item_single_choice android만빼고 이름만 바꿔 주었다-_-;;

복사한 simple_list_item_single_choice.xml 열어서 하고싶은 글자색 폰트사이즈 수정한다..

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:checkMark="?android:attr/listChoiceIndicatorSingle"
    android:gravity="center_vertical"
    android:paddingLeft="6dip"
    android:paddingRight="6dip"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#000000"
    android:textSize="16dp"
/>

내가 원하는 흰바탕의 리스트에 검은색 글씨를 만들었다..

xml파일에는 CheckedTextView로 만들어져있네.. 이거 잘활용하면 커스트마이징안하고 다른것들도 많이 만들어볼수있을듯..

 

Posted by 부르마