QuickScreenShare
http://portable.easylife.tw/2790
2015年5月7日 星期四
[Android] Element Image or background setting
Android
xml
=========================================
//下行為設定
background.setBackgroundColor(Color.RED);
//或是
background.setBackgroundColor(Color.parseColor("色碼")
ib_camStatus=(ImageButton) listView.getChildAt(camIndex).findViewById(R.id.ib_camStatus); // ib_camStatus.setBackgroundResource(R.drawable.blue_point); //背景 ib_camStatus.setImageResource(R.drawable.blue_point); //前景
xml
android:background="@drawable/blue_point" //背景 //android:background="@android:color/transparent" //背景透明 android:src="@drawable/red_point" //前景related reference http://www.bkjia.com/Androidjc/866967.html
=========================================
//下行為設定
background.setBackgroundColor(Color.RED);
//或是
background.setBackgroundColor(Color.parseColor("色碼")
2015年5月5日 星期二
[Android] thread communicate with UI thread by using message
put A part in thread, A part will send messages to main thread(UI thread). That is a way for sub thread to communicate with UI Thread.
A part:
B part:
A part:
// mainHandler.sendEmptyMessage(0);
Bundle result = new Bundle();
result.putInt("P2Pdone", 1);
Message msg = new Message();
msg.setData(result);
msg.what = 4; // message number
mainHandler.sendMessage(msg);
B part:
class MainHandler extends Handler {
static final int MSGTYPE_LOG =1;
static final int MSGTYPE_P2PTUNNEL_LOG=2;
static final int MSGTYPE_P2PLIVE_LOG=3;
@Override
public void handleMessage(Message msg) {
handleMsg(msg);
super.handleMessage(msg);
}
void handleMsg(Message msg)
{
switch(msg.what){
case MSGTYPE_LOG: //1
_printLog((String)msg.obj);
break;
case MSGTYPE_P2PTUNNEL_LOG: //2
{
}
break;
case MSGTYPE_P2PLIVE_LOG: //3 , ken
// txt_log.append(data+"\n");
txt_log.append(msg.getData().getString("data")+"\n");
break;
case 4: //4 , ken
if(msg.getData().getInt("P2Pdone")==1){
uiSwitch(SC_START);
}
default:;
}
}
}
2015年4月30日 星期四
[Android] change photo regularly
change photo in each two seconds.
http://stackoverflow.com/questions/1520887/how-to-pause-sleep-thread-or-process-in-android
2015年4月29日 星期三
[Android] check APP exist or not
以VLC APP為例
private View.OnClickListener marketListener=new View.OnClickListener() {
@Override
public void onClick(View v) {
if(isPackageExisted("org.videolan.vlc")){
Toast.makeText(getApplicationContext(), "the APP is exist.", Toast.LENGTH_SHORT).show();
}else{
// 尋找某個應用程式
Uri uri = Uri.parse("market://search?q=pname:org.videolan.vlc");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
}
}
};
public boolean isPackageExisted(String targetPackage){
PackageManager pm=getPackageManager();
try {
PackageInfo info=pm.getPackageInfo(targetPackage,PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
return false;
}
return true;
}
2015年4月22日 星期三
2015年4月21日 星期二
[Android] Android The method startActivity(Intent) is undefined
Android The method startActivity(Intent) is undefined for the type new View.OnClickListener(){}
You can pass the object activity class to the adapter, from which you are calling the adapter. Then use that object to call startActivity.
reference:
http://stackoverflow.com/questions/13983129/android-the-method-startactivityintent-is-undefined-for-the-type-new-view-oncl
http://stackoverflow.com/questions/17505969/how-to-fix-the-method-startactivityintent-is-undefined-for-the-type-new-view-o
訂閱:
文章 (Atom)