This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* use modulo operator to implement loops | |
*/ | |
public class Loop { | |
// index | |
private static int index; | |
// a objects array | |
private static obj[] mObjs = new obj[]{ | |
new obj(0), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* All activity data would be destoryed after the device rotate | |
* So we need save the data first and recall it after the device rotate | |
*/ | |
public class MainActiviy extends AppCompatActivity { | |
// example key variable | |
private static final String KEY_INDEX = "index"; | |
// example data variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
tools:context="com.example.PreviewLayoutActivity"> | |
<TextView | |
android:id="@+id/answer_text_view" | |
android:layout_width="wrap_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* public name: SendActivity | |
* comment: start activity(using intent) by calling static final method instead of creating one by itself. | |
*/ | |
public class SendActivity extends AppCompatActivity{ | |
... | |
//Start Receiver Activity | |
boolean exampleKey = someFunToGetExampleKey(); | |
Intent intent = ReceiveActivity.newIntent(SendActivity.this, exampleKey); | |
startActivity(intent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
var="$1" | |
xdg-open $(locate $var) > 2& |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
accerciser | |
adobe-source-code-pro-fonts | |
adobe-source-han-sans-cn-fonts | |
adobe-source-han-serif-cn-fonts | |
adwaita-icon-theme | |
aisleriot | |
alsa-utils | |
android-studio | |
anjuta | |
archlinuxcn-keyring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// global search REGEX | |
String regex="[^\\u4e00-\\u9fa5\\w]"; | |
Pattern pattern = Pattern.compile(regex); | |
Matcher matcher = pattern.matcher(data); | |
data = matcher.replaceAll(""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onDestroy() { | |
if(mWebView !=null ){ | |
mWebView.loadDataWithBaseURL(null, "", "text/html", | |
"utf-8", null); | |
((ViewGroup)mWebView.getParent()).removeView(mWebView); | |
mWebView.destroy(); | |
mWebView = null; | |
} | |
super.onDestroy(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Main { | |
public static void main(String[] args){ | |
B b = new B(); | |
System.out.println("-----"); | |
B bB = new B(12); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyFregment extends Fregment { | |
private static final int REQUEST_PHOTO = 2; | |
@Override | |
public View onCreateView(layoutflater inflater, ViewGroup container, Bundle savedinstanceState) { | |
mPhotoButton = (imageButton) v.findViewById(R.id.camera); | |
// 默认只能拍出低分辨率图片 | |
// 要想获得全尺寸照片,要让它使用文件系统存储图片 | |
// 需要传入保存在 MediaStore.EXTRA_OUTPUT 中的 Uri,该 Uri 会指向 FileProvider 提供的位置 | |
final Intent captureImage = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
OlderNewer