radiobutton 带小圆点_android开发中遇到的问题汇总(五)

本文汇总了Android开发中关于RadioButton的实践技巧,包括如何在TextView中设置drawableLeft,去锯齿,使用Xfermode进行图像处理,解决WebView视频播放控制问题,以及ListView和Handler的内存管理等常见问题和解决方案。同时,还涉及到了Android Studio的Gradle配置、Http请求头设置、IntentReceiver内存泄漏处理、Fragment通信等开发细节。
摘要由CSDN通过智能技术生成

127.ANDROID仿IOS时间_ANDROID仿IOS弹出提示框

128. Android TextView drawableLeft 在代码中实现

方法1php

Drawable drawable= getResources().getDrawable(R.drawable.drawable);

/// 这一步必需要作,不然不会显示.

drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());

myTextview.setCompoundDrawables(drawable,null,null,null);html

方法2java

public void setCompoundDrawablesWithIntrinsicBounds (Drawable left,

Drawable top, Drawable right, Drawable bottom)android

129. /* 去锯齿 */ paint.setAntiAlias(true);

130.android 画图之setXfermode

设置两张图片相交时的模式

咱们知道 在正常的状况下,在已有的图像上绘图将会在其上面添加一层新的形状。 若是新的Paint是彻底不透明的,那么它将彻底遮挡住下面的Paint;

而setXfermode就能够来解决这个问题

通常来讲 用法是这样的

[java] view plaincopy

Canvas canvas = new Canvas(bitmap1);

paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));

canvas.drawBitmap(mask, 0f, 0f, paint);

131. ubuntu android cordova

Setting up PhoneGap on Ubuntu for Android app development

132.webview的页面都finish了竟然还能听到视频播放的声音,查了下发现webview的

onResume方法能够继续播放,

onPause能够暂停播放,

可是这两个方法都是在Added in API level 11添加的,因此须要用反射来完成。

中止播放:在页面的onPause方法中使用:

webView.getClass().getMethod("onPause").invoke(webView,(Object[])null);

继续播放:在页面的onResume方法中使用:

webView.getClass().getMethod("onResume").invoke(webView,(Object[])null);

这样就能够控制视频的暂停和继续播放了。

在webView的Activity配置里面加上:

android:hardwareAccelerated="true"

133.Create new project on Android, Error: Studio Unknown host ‘services.gradle.org’

解决方法

please try following steps:

Go to..

File --> settings --> HTTP Proxy [Under IDE Settings] --> Auto-detect proxy settings

you can also use the test connection button and check with google.com if it works or not

[关于红杏的公益代理, Android Studio以及freso的编译](http://www.liaohuqiu.net/cn/posts/about-red-apricot-and-compiling-fresco/)

134.ListView.setOnItemClickListener 点击无效

若是ListView中的单个Item的view中存在checkbox,button等view,会致使ListView.setOnItemClickListener无效,

事件会被子View捕获到,ListView没法捕获处理该事件.

解决方法:

在checkbox、button对应的view处加android:focusable="false"

android:clickable="false"android:focusableInTouchMode="false"

其中focusable是关键

从OnClickListener调用getSelectedItemPosition(),Click 和selection 是不相关的,Selection是经过D-pad or trackball 来操做的,Click一般是点击操做的。

arg2参数才是点击事件位置的参数

135.listview addheader 若是有多个header,能够把多个header封装。把封装后的view做为header

136.emojicon

137.新闻评论页,如何实现盖楼,listview的高度自适应?

控件的高度 设为wrap_content

解决方法:

1.设置android:paddingLeft="25dip",就能够了。

2.设置checkbox的背景图片。系统默认的给checkbox加的有一个透明的背景。

myRequest.setRetryPolicy(new DefaultRetryPolicy(

MY_SOCKET_TIMEOUT_MS,

DefaultRetryPolicy.DEFAULT_MAX_RETRIES,

DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

140.Listview getItemViewType的使用 对于不一样xml,使用多个viewhold

thread = new Thread(){

@Override

public void run() {

try {

synchronized (this) {

wait(5000);

runOnUiThread(new Runnable() {

@Override

public void run() {

dbloadingInfo.setVisibility(View.VISIBLE);

bar.setVisibility(View.INVISIBLE);

loadingText.setVisibility(View.INVISIBLE);

}

});

}

} catch (InterruptedException e) {

e.printStackTrace();

}

Intent mainActivity = new Intent(getApplicationContext(),MainActivity.class);

startActivity(mainActivity);

};

};

thread.start();

142.Java SDK提供了对上述三种压缩技术的支持:Inflater类和Deflater类直接用zlib库对数据压缩/

解压缩,GZIPInputStream类和GZIPOutputStream类提供了对gzip格式的支持,ZipFile、Zi

pInputStream、ZipOutputStream则用于处理zip格式的文件。

因此,你应当根据你的具体需求,选择不一样的压缩技术:若是只须要压缩/解压缩数据,你

能够直接用zlib实现,若是须要生成gzip格式的文件或解压其余工具的压缩结果,你就必须

用gzip或zip等相关的类来处理了。

143.利用volley进行http设置请求头、超时及请求参数设置(post)

这里以post请求说明,get请求类似设置请求头及超时。

1.自定义request,继承com.android.volley.Request

2.构造方法实现(basecallback,为自定义的监听,实现Response.Listener,ErrorListener接口)--post请求

public BaseRequest(String url,String params, BaseCallback callback)

{

super(Method.POST, url, callback);

this.callback = callback;

this.params = params;

Log.e(TAG, "request:" + params);

setShouldCache(false);

}

3.请求头设置:重写getHeaders方法

@Override

public Map getHeaders() throws AuthFailureError

{

Map headers = new HashMap();

headers.put("Charset", "UTF-8");

headers.put("Content-Type", "application/x-javascript");

headers.put("Accept-Encoding", "gzip,deflate");

return headers;

}

设置字符集为UTF-8,并采用gzip压缩传输

4.超时设置:重写getRetryPolicy方法

@Override

public RetryPolicy getRetryPolicy()

{

RetryPolicy retryPolicy = new DefaultRetryPolicy(SOCKET_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);

return retryPolicy;

}

5.请求参数组装:重写getBody方法

@Override

public byte[] getBody() throws AuthFailureError

{

return params == null ? super.getBody() : params.getBytes();

}

144. android handler的警告Handler Class Should be Static or Leaks Occur

在使用Handler更新UI的时候,我是这样写的:

public class SampleActivity extends Activity {

private final Handler mLeakyHandler = new Handler() {

@Override

public void handleMessage(Message msg) {

// TODO

}

}

}

看起来很正常的,可是 Android Lint 却给出了警告:

This Handler class should be static or leaks might occur

意思是说:这个Handler 必须是static的,不然就会引起内存泄露。

其实,对于这个问题,Android Framework 的工程师 Romain Guy 早已经在Google论坛上作出过解释,而且给出了他的建议写法:

I wrote that debugging code because of a couple of memory leaks I

found in the Android codebase. Like you said, a Message has a

reference to the Handler which, when it's inner and non-static, has a

reference to the outer this (an Activity for instance.) If the Message

lives in the queue for a long time, which happens fairly easily when

posting a delayed message for instance, you keep a reference to the

Activity and "leak" all the views and resources. It gets even worse

when you obtain a Message and don't post it right away but keep it

somewhere (for instance in a static structure) for later use.

他的建议写法是:

class OuterClass {

class InnerClass {

private final WeakReference mTarget;

InnerClass(OuterClass target) {

mTarget = new WeakReference(target);

}

void doSomething() {

OuterClass target = mTarget.get();

if (target != null) {

target.do();

}

}

}

下面,咱们进一步解释一下:

1.Android App启动的时候,Android Framework 为主线程建立一个Looper对象,这个Looper对象将贯穿这个App的整个生命周期,它实现了一个消息队列(Message Queue),而且开启一个循环来处理Message对象。而Framework的主要事件都包含着内部Message对象,当这些事件被触发的时候,Message对象会被加到消息队列中执行。

2.当一个Handler被实例化时(如上面那样),它将和主线程Looper对象的消息队列相关联,被推到消息队列中的Message对象将持有一个Handler的引用以便于当Looper处理到这个Message的时候,Framework执行Handler的handleMessage(Message)方法。

3.在 Java 语言中,非静态匿名内部类将持有一个对外部类的隐式引用,而静态内部类则不会。

到底内存泄露是在哪里发生的呢?如下面代码为例:

public class SampleActivity extends Activity {

private final Handler mLeakyHandler = new Handler() {

@Override

public void handleMessage(Message msg) {

// ...

}

}

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

// Post a message and delay its execution for 10 minutes.

mLeakyHandler.postDelayed(new Runnable() {

@Override

public void run() { }

}, 60 * 10 * 1000);

// Go back to the previous Activity.

finish();

}

}

当Activity被finish()掉,Message 将存在于消息队列中长达10分钟的时间才会被执行到。这个Message持有一个对Handler的引用,Handler也会持有一个对于外部类(SampleActivity)的隐式引用,这些引用在Message被执行前将一直保持,这样会保证Activity的上下文不被垃圾回收机制回收,同时也会泄露应用程序的资源(views and resources)。

为解决这个问题,下面这段代码中的Handler则是一个静态匿名内部类。静态匿名内部类不会持有一个对外部类的隐式引用,所以Activity将不会被泄露。若是你须要在Handler中调用外部Activity的方法,就让Handler持有一个对Activity的WeakReference,这样就不会泄露Activity的上下文了,以下所示:

public class SampleActivity extends Activity {

/**

* Instances of static inner classes do not hold an implicit

* reference to their outer class.

*/

private static class MyHandler extends Handler {

private final WeakReference mActivity;

public MyHandler(SampleActivity activity) {

mActivity = new WeakReference(activity);

}

@Override

public void handleMessage(Message msg) {

SampleActivity activity = mActivity.get();

if (activity != null) {

// ...

}

}

}

private final MyHandler mHandler = new MyHandler(this);

/**

* Instances of anonymous classes do not hold an implicit

* reference to their outer class when they are "static".

*/

private static final Runnable sRunnable = new Runnable() {

@Override

public void run() { }

};

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

// Post a message and delay its execution for 10 minutes.

mHandler.postDelayed(sRunnable, 60 * 10 * 1000);

// Go back to the previous Activity.

finish();

}

}

总结:

在实际开发中,若是内部类的生命周期和Activity的生命周期不一致(好比上面那种,Activity finish()以后要等10分钟,内部类的实例才会执行),则在Activity中要避免使用非静态的内部类,这种状况,就使用一个静态内部类,同时持有一个对Activity的WeakReference。

146.FragmentPagerAdapter (getSupportFragmentManager() ) You must call removeView() on the child’s parent

How to solve for viewpager : The specified child already has a parent. You must call removeView() on the child's parent first

View res = inflater.inflate(R.layout.fragment_guide_search, container);

inside Fragment.onCreateView(...

You must call

View res = inflater.inflate(R.layout.fragment_guide_search, container, false);

or

View res = inflater.inflate(R.layout.fragment_guide_search, null);

参考:web

145. 使用代码为textview设置drawableLeft

Drawable drawable= getResources().getDrawable(R.drawable.drawable);

/// 这一步必需要作,不然不会显示.

drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());

myTextview.setCompoundDrawables(drawable,null,null,null);

146.Android如何在java代码中设置margin

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

lp.setMargins(10, 20, 30, 40);

imageView.setLayoutParams(lp);

147.出错了表现:Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536

解决:谷歌出了 新的Multidex支持库 androidstudio https://developer.android.com/tools/building/multidex.html

android {

compileSdkVersion 21

buildToolsVersion "21.1.0"

defaultConfig {

...

minSdkVersion 14

targetSdkVersion 21

...

// Enabling multidex support.

multiDexEnabled true

}

...

}

dependencies {

compile 'com.android.support:multidex:1.0.0'

}

148.How to get Nautilus-scripts working on Ubuntu 14.04?

nautilus-actions-config-tool

http://askubuntu.com/questions/281062/how-to-get-nautilus-scripts-working-on-ubuntu-13-04 设置好以后 nautilus -q。重启下nautilus服务生效

http://ubuntuhandbook.org/index.php/2014/04/ubuntu-14-04-add-open-as-rootadministrator-to-context-menu/

149. imageloader显示图片所使用的uri:

String imageUri = "http://site.com/image.png"; // from Web

String imageUri = "file:///mnt/sdcard/image.png"; // from SD card

String imageUri = "content://media/external/audio/albumart/13"; // from content provider

String imageUri = "assets://image.png"; // from assets

String imageUri = "drawable://" + R.drawable.image; // from drawables (only images, non-9patch)

注意:使用drawable://除非你真的须要他。时刻要注意使用本地图片加载方法:setImageResource带代替ImageLoader。

五,有用的信息

1,ImageLoader.getInstance().init(config); // 在应用开启的时候初始化。

2,sd卡缓存是须要写入权限

3,ImageLoader根据ImageView的width,height肯定图片的宽高。

4,若是常常出现OOM

①减小配置之中线程池的大小,(.threadPoolSize).推荐1-5;

②使用.bitmapConfig(Bitmap.config.RGB_565)代替ARGB_8888;

③使用.imageScaleType(ImageScaleType.IN_SAMPLE_INT)或者try.imageScaleType(ImageScaleType.EXACTLY);

④避免使用RoundedBitmapDisplayer.他会建立新的ARGB_8888格式的Bitmap对象;

⑤使用.memoryCache(new WeakMemoryCache()),不要使用.cacheInMemory();

5,内存缓存,sd卡缓存,显示图片,可使用已经初始化过的实现;

6,为了不使用list,grid,scroll,你可使用

boolean pauseOnScroll = false; // or true

boolean pauseOnFling = true; // or false

PauseOnScrollListener listener = new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling);

listView.setOnScrollListener(listener);

150.View’s getWidth() and getHeight() returning 0

You should use: image1.getLayoutParams().width; http://stackoverflow.com/questions/18268915/views-getwidth-and-getheight-returning-0

151.GridView的行数问题

在gridview里边设置属性 android:numColumns="3";意思是三列 而后在BaseAdapter的 getCount()方法 里边返回9。这样就能够平分为3行3列了

ArrayList提供public T[] toArray(T[] a)

public static List asList(T... a)

153.Unexpected response code 500

网页已经被关闭

还有就是,通常因为内部服务器错误形成的。

服务器关闭或者服务器升级而形成的资源没法访问

因为服务器太忙而形成的,此时没法处理请求。通信量超出 Web 站 点的能力

154. banner广告及view pager 的小圆点指示器 CirclePageIndicator http://9437752.blog.51cto.com/9427752/1580984

157.ViewPager FragmentPagerAdapter Nullpointer fragmentpageradapter和pageradapter的区别。使用的场景。

Overriding onMeasure of your ViewPager as follows will make it get the height of the biggest child it currently has.

@Override

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

int height = 0;

for(int i = 0; i < getChildCount(); i++) {

View child = getChildAt(i);

child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));

int h = child.getMeasuredHeight();

if(h > height) height = h;

}

heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);

super.onMeasure(widthMeasureSpec, heightMeasureSpec);

}

159.在自定义视图布局文件中,仅支持FrameLayout、LinearLayout、RelativeLayout三种布局控件和AnalogClock、Chronometer、Button、ImageButton、ImageView、ProgressBar、TextView、ViewFlipper、ListView、GridView、StackView和AdapterViewFlipper这些显示控件,不支持这些类的子类或Android提供的其余控件。不然会引发ClassNotFoundException异常

160.Android模拟器Genymotion加载ARM架构so文件

http://www.eoeandroid.com/thread-552875-1-1.html

https://www.genymotion.com/#!/support?chapter=collapse-logs#faq

161.Viewpager wrap_hight致使不显示。 重写ViewPager

/**

* for bug : unable to have ViewPager WRAP_CONTENT

*/

@Override

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

int hight = 0;

for (int i = 0; i < getChildCount(); i++) {

View child = getChildAt(i);

child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));

int h = child.getMeasuredHeight();

if (h > hight) hight = h;

}

heightMeasureSpec = MeasureSpec.makeMeasureSpec(hight, MeasureSpec.EXACTLY);

super.onMeasure(widthMeasureSpec, heightMeasureSpec);

}

162.选择项有RadioGroup和另一个button组成 点击button的时候,清除radiogroup中选中的radiobutton。调用radiogroup的clearCheck方法便可

163.gridview columnnum。上传照片

164. 9.png Error:Must have one-pixel frame that is either transparent or white. -xxx/app/src/main/res/drawable-xhdpi/icon_addpic_focused.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited

解决方法以下

this is the problem with latest adt that is 20.0.3. you can instead rename the .9.png to.png and start working. i think this is the bug with the adt only, since for 18.0.0 version adt it doesnt prompts for this type of error and works fine

165. IntentRecieverLeakedException, Are you missing a call to unregisterReceiver() ? in android

注册广播接收者有两种方式,一种在清单文件中注册。这个是长期有效的。另一种是。在activity中注册,这种注册的生命周期在actity的生命周期内,还有第二种注册不要registerReceiver必需要和unregisterReceiver配套使用,不然会出现上述问题。

http://stackoverflow.com/questions/9078390/intentrecieverleakedexception-are-you-missing-a-call-to-unregisterreceiver

There was nothing in the repository, until I did Share Directory on the project. It then created the folder for the project in the repository. I entered the following in Settings|Version Control|Subversion:

File:.idea/workspace.xml

File: .gradle

Directory: build/

Mask: *.iws

Directory: .idea/libraries/

Directory: app/build/

File: local.properties

下面的更完全

*.iml

*.iws

*.ipr

.idea/

.gradle/

local.properties

*/build/

*~

*.swp

167. packagingOptions {

exclude 'META-INF/LICENSE.txt'

exclude 'META-INF/NOTICE.txt'

}

168.CLEAN

Android Studio fails to debug with error org.gradle.process.internal.ExecException

Error:Execution failed for task ‘:app:dexDebug’.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘C:\Program Files\Java\jdk1.7.0_11\bin\java.exe” finished with non-zero exit value 2

169.Eclipse混淆文件导入Android Studio Gradle编译报input jar file is specified twice http://blog.csdn.net/X_i_a_o_H_a_i/article/details/41979983

缘由是build.gradle文件配置了

dependencies {

compile fileTree(include: ‘*.jar’, dir: ‘libs’)

}

里面已经添加过jar包,混淆文件proguard-rules.pro里面又加了句-libraryjars libs/.jar,将-libraryjars libs/.jar 前面用#号注释或者直接删掉便可。

对设置为“UTF-8”编码的文件在修改后保存时自动加入了UTF-8文件签名,即BOM(将文件以十六进制形式查看,可见文件首部为“EF BB BF”).

解决方法:

使用Notepad++去除BOM 【在IntelliJ IDEA 12使用,可成功】

具体方法:先设置以UTF-8无ROM方式编码,而后打开文件,另存此文件,覆盖掉原文件。

设置方法:格式->以UTF-8无ROM方式编码。

171.LocalBroadcastManager 解决fragment中通讯的问题

最近在开发平板项目,彻底是fragmentactivity+fragment的结构。看起来彷佛简单,可是和之前不一样的是,业务逻辑很是复杂,多处的很是规跳转,

fragment之间的数据交换,一处更新多处更新等操做,有时玩起来都心塞。项目背景介绍完毕。

如今有这样一个场景,项目需求是,后台可配置功能,也就是说app端全部的功能都是后台配置上去的动态生成,对应的功能界面以下图。

可以完成在应用内的广播发送,并且比全局广播更具优点:

1).广播只会在你的应用内发送,因此无需担忧数据泄露,更加安全。

2).其余应用没法发广播给你的应用,因此也不用担忧你的应用有别人能够利用的安全漏洞

3).相比较全局广播,它不须要发送给整个系统,因此更加高效。

2. 使用方式

广播注册:

LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(getActivity());

IntentFilter filter = new IntentFilter();

filter.addAction(ACTION);

myBroadcastReciver = new MyBroadcastReciver();

localBroadcastManager.registerReceiver(myBroadcastReciver, filter);

复制代码

广播发送:

Intent intent = new Inten();

intent.setAction(SaleLeftFragment.ACTION);

intent.putExtra(TAG, data);

LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intent);

复制代码

3.使用注意

在使用的时候,请关注如下几点:

1).LocalBroadcastManager注册广播只能经过代码注册的方式。

2).LocalBroadcastManager注册广播后,必定要记得取消监听。

3).重点的重点,使用LocalBroadcastManager注册的广播,您在发送广播的时候务必使用

Fragment间的广播消息接收

广播注册,能够写在Activity(onCreate),也能够写在Fragment(onActivityCreated)里。

复制代码

LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());

IntentFilter intentFilter = new IntentFilter();

intentFilter.addAction("android.intent.action.CART_BROADCAST");//建议把它写一个公共的变量,这里方便阅读就不写了。

BroadcastReceiver mItemViewListClickReceiver = new BroadcastReceiver() {

@Override

public void onReceive(Context context, Intent intent){

System.out.println("OK");

}

};

broadcastManager.registerReceiver(mItemViewListClickReceiver, intentFilter);

复制代码

发送广播

Intent intent = new Intent("android.intent.action.CART_BROADCAST");

LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intent);

172.[How can I] Change the password, so I can share it with others and let them sign

Using keytool:

keytool -storepasswd -keystore /path/to/keystore

Enter keystore password: changeit

New keystore password: new-password

Re-enter new keystore password: new-password

173.How to create a release signed apk file using Gradle?

174.No activity found to handle intent action.dial

Uri.parse(“tel:” + a1)

Android 调用系统Email –多附件

Intent.ACTION_SENDTO 无附件的发送

Intent.ACTION_SEND 带附件的发送

Intent.ACTION_SEND_MULTIPLE 带有多附件的发送

Intent data=new Intent(Intent.ACTION_SENDTO);

data.setData(Uri.parse(“mailto:455245521@qq.com”));

data.putExtra(Intent.EXTRA_SUBJECT, “这是标题”);

data.putExtra(Intent.EXTRA_TEXT, “这是内容”);

startActivity(data);

175.HTML 中有用的字符实体

注释:实体名称对大小写敏感!

显示结果 描述 实体名称 实体编号

空格

< 小于号 < <

大于号 > >

& 和号 & &

” 引号 " "

’ 撇号 ' (IE不支持) '

¢ 分 ¢ ¢

£ 镑 £ £

¥ 日圆 ¥ ¥

€ 欧元 € €

§ 小节 § §

© 版权 © ©

® 注册商标 ® ®

™ 商标 ™ ™

× 乘号 × ×

÷ 除号 ÷ ÷

How to create a release signed apk file using Gradle? http://stackoverflow.com/questions/18328730/how-to-create-a-release-signed-apk-file-using-gradle

android {

compileSdkVersion 17

signingConfigs {

releaseSigning {

storeFile file(System.getenv("ANDROID_KEYSTORE"))

storePassword System.console().readLine("\nStore password: ")

keyAlias System.getenv("ANDROID_KEYALIAS")

keyPassword System.console().readLine("Key password: ")

}

}

buildTypes {

release {

signingConfig signingConfigs.releaseSigning

}

}

}

Now, you can generate the signed and zipaligned release APK using the Gradle task:

./gradlew assembleRelease

177.Android Studio: How to use Monitor(DDMS) tool to debug application step by step?

Go to "Tools > Android > Android Device Monitor" in v0.8.6. That will pull up the DDMS eclipse perspective.

dump viewhierarchy for ui automator 能够查看应用的布局,当对某个app布局感兴趣时,能够采用此种方式查看此app的布局,至关于布局反编译功能。

178. 如何经过java代码设置textview字体加粗。

textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//加粗

179.qickreturn swiperefreshlayout

viewpager在加载当前页的时候已经将pager页左右页的内容加载进内存里了,这样才保证了viewpager左右滑动的时候的流畅性;

为了解决完全删除fragment,咱们要作的是:

1.将FragmentPagerAdapter 替换成FragmentStatePagerAdapter,由于前者只要加载过,fragment中的视图就一直在内存中,在这个过程当中不管你怎么刷新,清除都是无用的,直至程序退出; 后者 能够知足咱们的需求。

2.咱们能够重写Adapter的方法--getItemPosition(),让其返回PagerAdapter.POSITION_NONE便可;

181. Uri.encode

182.omniplan mac

183.androidstudio svn delete

184.GreenDao query OR within AND

http://stackoverflow.com/questions/22785327/greendao-query-or-within-and

QueryBuilder.and() and QueryBuilder.or() are used to combine WhereConditions. The resulting WhereConditions have to be used inside QueryBuilder.where() (which will combine the conditions using AND) or QueryBuilder.whereOr().

185.greendao 删除某个对象

http://www.cnblogs.com/spring87/p/4364769.html

1.public void deleteCityInfo(int cityId)

2.{

3.QueryBuilder qb = cityInfoDao.queryBuilder();

4.DeleteQuery bd = qb.where(Properties.CityId.eq(cityId)).buildDelete();

5.bd.executeDeleteWithoutDetachingEntities();

6.}

187. androidstudio ctrl+shift+t 模糊搜索类

ctrl+o 本文件的函数

ctrl+g 全局搜索类 变量 函数

alter+insert 快速插入getset等

Ctrl+Shift+F7 能够高亮当前元素在当前文件中的使用

Android Studio 如何提示函数用法? 先选中,而后按F2

188.Fragment的通讯有关问题, 新建Fragment为什么不要在构造方法中传递参数

189.

在理解反射的时候,不得不说一下内存。

先理解一下JVM的三个区:堆区,栈区,和方法去(静态区)。

堆区:存放全部的对象,每一个对象都有一个与其对应的class信息。在JVM中只有一个堆区,堆区被全部的线程共享。

栈区:存放全部基础数据类型的对象和全部自定义对象的引用,每一个线程包含一个栈区。每一个栈区中的数据都是私有的,其余栈不能访问。

栈分为三部分:

基本类型变量区、执行环境上下文、操做指令区(存放操做指令)。

方法区:即静态区,被全部的线程共享。方法区包含全部的class和static变量。它们都是惟一的。

在启动一个java虚拟机时,虚拟机要加载你程序里所用到的类 ,这个进程会首先跑到jdk中(在jdk的jre/lib/ext文件夹里找那些jar文件),若是没有找到,会去classpath里设置的路径去找。

在找到要执行的类时:

1.首先将找到的类的信息加载到运行时数据区的方法区。这个过程叫作类的加载。因此一下static类型的在类的加载过程当中就已经放到了方法区。因此不用实例化就能用一个static类型的方法。

2.加载完成后,在new一个类时,首先就是去方法区看看有没有这个类的信息。若是没有这个类的信息,先装载这个类。then,加载完成后,会在堆区为new的这个类分配内存,有了内存就有了实例,而这个实例指向的是方法区的该类信息。其实就是存放了在方法区的地址。而反射就是利用了这一点。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值