android開發中遇到的問題彙總

android開發中遇到的問題彙總(五),android彙總


127.ANDROID仿IOS時間_ANDROID仿IOS彈出提示框
http://dwtedx.com/itshare_297.html


128. Android TextView drawableLeft 在代碼中實現
方法1


Drawable drawable= getResources().getDrawable(R.drawable.drawable); 
/// 這一步必須要做,否則不會顯示. 
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); 
myTextview.setCompoundDrawables(drawable,null,null,null);


方法2


public void setCompoundDrawablesWithIntrinsicBounds (Drawable left, 
Drawable top, Drawable right, Drawable bottom)


129. /* 去鋸齒 */ paint.setAntiAlias(true);
130.android 畫圖之setXfermode
http://blog.csdn.net/wm111/article/details/7299294 
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
emojicon, https://github.com/rockerhieu/emojicon 
emojicon, https://github.com/ankushsachdeva/emojicon


137.新聞評論頁,如何實現蓋樓,listview的高度自適應?
控件的高度 設爲wrap_content
138.android改變CheckBox和後面文字的間距 http://www.haodaima.net/art/1891872
解決方法:
1.設置android:paddingLeft="25dip",就可以了。
2.設置checkbox的背景圖片。系統默認的給checkbox加的有一個透明的背景。
139.volley請求超時 如何處理 http://stackoverflow.com/questions/17094718/android-volley-timeout
myRequest.setRetryPolicy(new DefaultRetryPolicy(
            MY_SOCKET_TIMEOUT_MS, 
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES, 
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));  
140.Listview getItemViewType的使用 對於不同xml,使用多個viewhold
141.Android “Only the original thread that created a view hierarchy can touch its views.” http://stackoverflow.com/questions/5161951/android-only-the-original-thread-that-created-a-view-hierarchy-can-touch-its-vi
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<T> callback)
    {
    super(Method.POST, url, callback);
    this.callback = callback;
    this.params = params;
    Log.e(TAG, "request:" + params);
    setShouldCache(false);
    }
3.請求頭設置:重寫getHeaders方法


 @Override
    public Map<String, String> getHeaders() throws AuthFailureError
    {
    Map<String, String> headers = new HashMap<String, String>();
    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<OuterClass> mTarget;


    InnerClass(OuterClass target) {
       mTarget = new WeakReference<OuterClass>(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<SampleActivity> mActivity;


    public MyHandler(SampleActivity activity) {
      mActivity = new WeakReference<SampleActivity>(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
http://stackoverflow.com/questions/13559353/how-to-solve-for-viewpager-the-specified-child-already-has-a-parent-you-must 
解決方法 
I had the same problem when I used


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);
參考:


[1]https://groups.google.com/forum/?fromgroups=#!msg/android-developers/1aPZXZG6kWk/lIYDavGYn5UJ 
[2]http://www.androiddesignpatterns.com/2013/01/inner-class-handler-memory-leak.html 
[3]http://stackoverflow.com/questions/11407943/this-handler-class-should-be-static-or-leaks-might-occur-incominghandler


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,<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>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列了
152.ArrayList和數組間的相互轉換 http://wanglihu.iteye.com/blog/243238
ArrayList提供public <T> T[] toArray(T[] a)


public static <T> List<T> asList(T... a)
153.Unexpected response code 500
網頁已經被關閉
還有就是,一般由於內部服務器錯誤造成的。
  服務器關閉或者服務器升級而造成的資源無法訪問
  由於服務器太忙而造成的,此時無法處理請求。通訊量超出 Web 站 點的能力
154. banner廣告及view pager 的小圓點指示器 CirclePageIndicator http://9437752.blog.51cto.com/9427752/1580984
155.使用ViewPager+GridView實現橫向滑動的效果 http://blog.csdn.net/developer_jiangqq/article/details/9364501
156.CircleImageView https://github.com/hdodenhof/CircleImageView
157.ViewPager FragmentPagerAdapter Nullpointer fragmentpageradapter和pageradapter的區別。使用的場景。
158.unable to have ViewPager WRAP_CONTENT http://stackoverflow.com/questions/8394681/android-i-am-unable-to-have-viewpager-wrap-content
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
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 前面用#號註釋或者直接刪掉即可。


170.key.java android-stuido 中錯誤提示:“非法字符: \65279” http://www.cnblogs.com/littlehb/archive/2013/04/20/3032721.html
對設置爲“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?
http://stackoverflow.com/questions/18328730/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:[email protected]”)); 
data.putExtra(Intent.EXTRA_SUBJECT, “這是標題”); 
data.putExtra(Intent.EXTRA_TEXT, “這是內容”); 
startActivity(data);


175.HTML 中有用的字符實體
註釋:實體名稱對大小寫敏感! 
顯示結果 描述 實體名稱 實體編號 
空格     
< 小於號 < <


大於號 > > 
& 和號 & & 
” 引號 " " 
’ 撇號 ' (IE不支持) ' 
¢ 分 ¢ ¢ 
£ 鎊 £ £ 
¥ 日圓 ¥ ¥ 
€ 歐元 € € 
§ 小節 § § 
© 版權 © © 
® 註冊商標 ® ® 
™ 商標 ™ ™ 
× 乘號 × × 
÷ 除號 ÷ ÷


176.Generating signed release APK using Gradle https://github.com/almalkawi/Android-Guide/wiki/Generating-signed-release-APK-using-Gradle
 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
180. viewpager中徹底性動態添加、刪除Fragment http://stackoverflow.com/questions/10396321/remove-fragment-page-from-viewpager-in-android
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爲何不要在構造方法中傳遞參數
http://233.io/article/1057296.html


189.
在理解反射的時候,不得不說一下內存。 
先理解一下JVM的三個區:堆區,棧區,和方法去(靜態區)。 
堆區:存放所有的對象,每個對象都有一個與其對應的class信息。在JVM中只有一個堆區,堆區被所有的線程共享。 
棧區:存放所有基礎數據類型的對象和所有自定義對象的引用,每個線程包含一個棧區。每個棧區中的數據都是私有的,其他棧不能訪問。 
棧分爲三部分: 
基本類型變量區、執行環境上下文、操作指令區(存放操作指令)。 
方法區:即靜態區,被所有的線程共享。方法區包含所有的class和static變量。它們都是唯一的。


在啓動一個java虛擬機時,虛擬機要加載你程序裏所用到的類 ,這個進程會首先跑到jdk中(在jdk的jre/lib/ext文件夾裏找那些jar文件),如果沒有找到,會去classpath裏設置的路徑去找。
在找到要執行的類時:
1.首先將找到的類的信息加載到運行時數據區的方法區。這個過程叫做類的加載。所以一下static類型的在類的加載過程中就已經放到了方法區。所以不用實例化就能用一個static類型的方法。
2.加載完成後,在new一個類時,首先就是去方法區看看有沒有這個類的信息。如果沒有這個類的信息,先裝載這個類。then,加載完成後,會在堆區爲new的這個類分配內存,有了內存就有了實例,而這個實例指向的是方法區的該類信息。其實就是存放了在方法區的地址。而反射就是利用了這一點。
android開發中遇到的問題彙總【六】,android彙總


190. Genymotion Crash after a few minutes
E/eglCodecCommon(2163): writeFully: failed: Broken pipe


http://stackoverflow.com/questions/23855115/genymotion-crash-after-a-few-minutes


It's not really caused by your application, so don't worry.


It often happens when you computer goes in sleep mode and when you come back Genymotion will throw this exception (it happens to me very often).


In your specific case sounds like the device goes in sleep mode so a way to fix it is simply to enable "Always stay awake" in developers options.
192. A WebView method was called on thread ‘Timer-1’. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.
java.lang.IllegalStateException: Timer was canceled 
at java.util.Timer.scheduleImpl(Timer.java:561) 
at java.util.Timer.schedule(Timer.java:481) 
at com.jetsun.hbfc.activity.base.CommonWebViewActivity$3.onPageStarted(CommonWebViewActivity.java:178)


Webview reload page get force close


Change your TimerTask to the following:


new TimerTask() { 
@Override 
public void run() { 
runOnUiThread(new Runnable() { 
public void run() { 
wvNovaMenzaCammera.reload(); 
} 
}); 
} 
}


193.http://blog.csdn.net/xieyuooo/article/details/8607220
Timer與TimerTask的真正原理&使用介紹


194.http://233.io/article/1057296.html Fragment的通信有關問題, 新建Fragment爲何不要在構造方法中傳遞參數
195.Add a new file in Intellij doesn’t add to subversion
http://stackoverflow.com/questions/2817452/add-a-new-file-in-intellij-doesnt-add-to-subversion
    Go to File -> Settings -> Version control -> Confirmation -> When files are created You're probably looking for "Add silently".
196.使用Android Studio的lint清除無用的資源文件 http://waychel.com/shi-yong-android-studiode-lintqing-chu-wu-yong-de-zi-yuan-wen-jian/
197. Android應用程序release打簽名包時,出現錯誤:”XXX” is not translated in “af” (Afrikaans), “am” (Amharic), “ar” (Arabic)…..
eclipse 
http://blog.csdn.net/u012264122/article/details/39371343


androidstudio http://stackoverflow.com/questions/20699147/gradle-build-fails-on-lint-task


// This is important, it will run lint checks but won't abort build
  lintOptions {
      abortOnError false
  }




if abortOnError false will not resolve your problem, you can try this.


lintOptions {
    checkReleaseBuilds false
}
198.
全面提高Ubuntu Linux操作系統運行速度


1.六招讓你的Ubuntu馬上提速  http://article.yeeyan.org/view/205625/294577




       Where did the startup-applications-preferences program go?  ubuntu satartup applications preference
     http://askubuntu.com/questions/159887/where-did-the-startup-applications-preferences-program-go
    The if you can't find the program anywhere, try running gnome-session-properties from the command line (or alt+f2).


    If it's not installed, I'm sure you can install the package gnome-session-properties.


2. 將localhost化名爲主機名


    據說這個方法可以改善使用Ubuntu一段後,在GNOME中啓動應用程序變慢的問題


    # vi /etc/hosts


    127.0.0.1 localhost


    127.0.1.1 Ubuntu


    ===>


    127.0.0.1 localhost Ubuntu


    127.0.1.1 Ubuntu


    注:在第一行末尾加上主機名,也就是第二行的那個名字。


3.安裝preload


    可以把一些常用到的lib庫和應用程序預加載到內存,以提高程序的啓動速度


    # apt-get install preload
199.volley由於網絡訪問比較慢,導致訪問兩次的現象 http://stackoverflow.com/questions/22428343/android-volley-double-post-when-have-slow-request?
    http://stackoverflow.com/questions/3352424/httpurlconnection-openconnection-fails-second-time
200.當你想讓一個高度值不足scrollview的子控件fillparent的時候,單獨的定義 android:layout_height=”fill_parent”是不起作用的,必須加上fillviewport屬性,當子控件的高度值大於 scrollview的高度時,這個標籤就沒有任何意義了。
201.activity FLAG_ACTIVITY_REORDER_TO_FRONT 無法startActivity http://blog.csdn.net/mingli198611/article/details/8678513
202. Genymotion模擬器運行項目 jPush報錯jpush Couldn’t load jpush: findLibrary returned null
at cn.jpush.android.api.JPushInterface.init(Unknown Source)


203.androidstudio檢查更新。Android Studio支持自動檢查更新。之前尚未發佈正式版時,一週有時會有幾次更新。你可以設置檢查的類型,用以控制更新類型。
Settings --> Updates 。勾選 Check for updates in channel ,即開通了自動檢查更新。你可以禁用自動檢查更新。右側的列表,是更新通道。
Stable Channel : 正式版本通道,只會獲取最新的正式版本。
Beta Channel : 測試版本通道,只會獲取最新的測試版本。
Dev Channel : 開發發佈通道,只會獲取最新的開發版本。
Canary Channel : 預覽發佈通道,只會獲取最新的預覽版本。rc  release candidates
以上4個通道中, Stable Channel 最穩定,問題相對較少, Canary Channel 能獲得最新版本,問題相對較多。


204.AndroidのActivity之Listview組件快速拖動 android:fastScrollEnabled=”true” android:focusable=”true”
205. Lint: How to ignore “ is not translated in ” errors?
http://stackoverflow.com/questions/11443996/lint-how-to-ignore-key-is-not-translated-in-language-errors 
To ignore this in a gradle build add this to the android section of your build file:


lintOptions { 
disable ‘MissingTranslation’ 
}


Authentication Error errorcode: 201 uid: -1 appid -1 msg: APP被用戶自己禁用


ubuntu apktool 2.0 Exception in thread “main” brut.androlib.err.UndefinedResObject


keytool -list -keystore SportsApp.keystore


206.Exception in thread “main” brut.androlib.AndrolibException: Could not decode arsc file
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:56)
at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:491)
at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:74)
at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:66)
at brut.androlib.Androlib.getResTable(Androlib.java:50)
at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:189)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:114)
at brut.apktool.Main.cmdDecode(Main.java:146)
at brut.apktool.Main.main(Main.java:77)
Caused by: java.io.IOException: Expected: 0x001c0001, got: 0x00000000 
at brut.util.ExtDataInput.skipCheckInt(ExtDataInput.java:48) 
at brut.androlib.res.decoder.StringBlock.read(StringBlock.java:44) 
at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:102) 
at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:83) 
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49) 
… 8 more


It seems there’s some problem in building the resources while recompiling the apk. what you can do is, when you decompile your apk use this command


apktool d -f -r apkfilename.apk 
here -f is to replace previous decompiled apk’s code and -r is to ignore the decompiling of resources.


this would prevent the resources from being decompiled and will simply copy the same resources when you recompile the apk.


208 android sharesdk微信分享 創建應用時所需的應用簽名怎麼得到
根據這個頁面提供的一個工具 簽名生成工具 
https://open.weixin.qq.com/cgi-bin/readtemplate?t=resource/app_download_android_tmpl&lang=zh_CN 
Android資源下載 
開發工具包 
開發第三方應用所需要的庫以及文件。點擊下載 
範例代碼 
包含了一個完整的範例工程。該範例的使用可以參閱Android平臺上手指南:HelloWeixin@Android。點擊下載 
簽名生成工具用於獲取安裝到手機的第三方應用簽名的apk包。點擊下載


可以一個字符串,類似於: 
應用簽名:049a9fde46bfc5087f3825582208b248 
安裝這個應用可以獲取本手機已經安裝的某個android軟件,根據軟件的包名,類似於: com.demo.AppX 來查找這個軟件,以及獲取這個軟件的 應用簽名。 
還有一個工具是在 
http://wiki.open.qq.com/wiki/mobile/SDK下載 
Android_SDK_V2.3.1 的tools目錄下有一個 獲取簽名.apk ,這個也可以獲取,但是我測試發現,只能顯示一部分的本機應用,有些應用查不到,就麻煩了..


209.:app:lintVitalRelease
Failed converting ECJ parse tree to Lombok for file /home/yyb/work/BoShiTong/trunk/HBFC/Android/Comment/HBFC-AS2/app/src/main/java/com/jetsun/hbfc/widget/ioc/AbIocView.java 
java.lang.ClassCastException: lombok.ast.Annotation cannot be cast to lombok.ast.Expression


210. Ignoring InnerClasses attribute for an anonymous inner class
211.WebView 在Android4.4的手機上onPageFinished()回調會多調用一次(具體原因待追查)
需要儘量避免在onPageFinished()中做業務操作,否則會導致重複調用,還有可能會引起邏輯上的錯誤. 
onPageStarted和onPageFinished 會加載兩次




android開發中遇到的問題彙總【七】
212.Android WebView常見問題及解決方案彙總
http://blog.csdn.net/t12x3456/article/details/13769731


213.Android check network connectivity on some tablets crash
java.lang.NullPointerException 
at com.xxx.Util.getNetworkState(Util.java:246)


214.What is the equivalent of Eclipse “Custom debug Keystore” in Android studio?
http://stackoverflow.com/questions/17189076/what-is-the-equivalent-of-eclipse-custom-debug-keystore-in-android-studio
215.Android Studio在調試時,修改變量的值 在“Variables”窗口中,選擇需要修改的變量,然後右鍵,選“Set Value…”。快捷鍵F2
216.打開百度定位導致MyApplication中的初始化重新加載一遍。如果此時有自動登錄等,會導致重新登錄 而目前的憑證失效
217.android webview和js交互json對象 。通過字符串傳遞。然後通過jsonobject把字符串生成json對象從中獲取數據。
218. Android Studio開發jni ndk
主要有以下三塊 
1. Javah生成JNI頭文件 
需要進入到/src/mian 這個目錄下 。如果不進入這個目錄等會運行javah的時候會提示: 錯誤: 找不到 ‘com.lcj.ndk_demo_2.HelloNDK’ 的類文件 
javah -d jni -classpath ….\build\intermediates\classes\debug com.lcj.ndk_demo_2.HelloNDK 
jni 是生成的頭文件需要存放的文件夾(一般取名jni纔對) 
….\build\intermediates\classes\debug 是class所在目錄(Build—>Make Project生成的class文件都在這裏,這是一個相對路徑) 
com.lcj.ndk_demo_2.HelloNDK 是class文件的文件名(根據之前的java文件生成的) 
參考 http://wenku.baidu.com/view/105474098e9951e79b8927a3.html 
2.根據上不生成的.h文件 寫.c和makefile 
3.ndk-build【這個androidstudio1.2已經集成,可以直接編譯ndk,所以多一個選擇】 
易出現的問題 When running the ndk-build command I get the following error:


Android NDK: Could not find application project directory !    
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it


解決方案


NDK_PROJECT_PATH is an environment variable so you don't have to include in the Android.mkfile. Is nkd-build launched in the project directory?


For more info read the docs in docs/HOWTO.html in the NDK folder where I read


Starting with NDK r4, you can simply place the file under $PROJECT/jni/ and launch the 'ndk-build' script from your project tree.


If you want to use 'ndk-build' but place the file to a different location, use a GNU Make variable override as:


ndk-build NDK_APPLICATION_MK=/path/to/your/Application.mk
219.Android下使用lamemp3庫將PCM錄音數據壓縮爲MP3格式
        文章最下面有demo 很不錯 通過javah修改下,可以直接用
   來源:    http://ikinglai.blog.51cto.com/6220785/1228730
220.Android Studio 不自動彈起代碼提示功能解決辦法 do not auto popup code completion
升級後不自動彈起代碼提醒功能了,而且變量也不標註顏色,簡直是氣死我了,Google了各種關鍵詞,都沒辦法 
後來看到有個Power Save Mode,昨天看到筆記本發熱厲害就給勾上了,是不是這個原因呢? 
取消之後一切正常,看來是省電模式下禁用了這些功能,通過反射來實現代碼的autoComplete是會增加CPU運算量。


File–>Power Save Mode .勾掉省電模式 
參考:http://blog.csdn.net/ameryzhu/article/details/14105275


221. 百度地圖相關 在Genymotion上啓動項目時,程序拋出異常
222. 百度地圖相關。E/baidumapsdk﹕ Authentication Error errorcode: -1 uid: -1 appid -1 msg: AndroidManifest.xml的application中沒有meta-data標籤
223. 百度地圖相關 百度地圖去掉縮放按鈕
MapView放在ScrollView中,滾動時出現黑條 
http://bbs.lbsyun.baidu.com/forum.php?mod=viewthread&tid=1093 
應該GLSurfaceView放在ScrollView內部的問題.1.3.5用View直接繪製沒有問題.能否在下版中提供一個底層基於View繪製的MapView


版主,我在想,當滾動用截取當前地圖的bitmap.(調用getCurrentMap())然後蓋在GLSurface上.但getCurrentMap()操作是異步的,用android自帶的View.getDrawingCache()也未能成功獲取.上述不成功後,由於需求限制可以對地圖不操作,嘗試了下能不能再MapView完成地圖加載後getCurrentMap()把截圖放在ImageView中蓋在MapView上,但未能找到相應的監聽方法.見貼:http://bbs.lbsyun.baidu.com/viewthread.php?tid=1104&extra=page%3D1.現在改用1.3.5在做.QQ:396920165能否交流下


scrollview內嵌mapview後的滑動問題


百度地圖mapview放在scrollview中滑動黑屏


後面我試下了直接用截圖功能。mapview設置隱藏,然後方法沒被執行。是不是在mapview 不顯示的情況下。截圖功能不可用? 
開始移動前截圖覆蓋 
靜態。不可拖動但是可要能點擊


建議不要在scroll中使用mapview 因爲本身map是用opengl繪製的,這個東西在scroll中存在性能問題,所以導致的體驗效果不佳,請考慮改變實現方式。


百度map1.3.5 
http://developer.baidu.com/map/reference/index.php?title=Class:android%E6%A0%B8%E5%BF%83%E7%B1%BB/MapView


靜態【不可放大縮小】的mapview。點擊無效


http://www.cnblogs.com/trinea/archive/2012/11/14/2770433.html


224.Android自定義DataTimePicker(日期選擇器) http://blog.csdn.net/wwj_748/article/details/38778631
225.Content-Type: application/x-www-form-urlencoded;
可以通過mitmproty分析


https://www.imququ.com/post/four-ways-to-post-data-in-http.html


四種常見的 POST 提交數據方式


application/x-www-form-urlencoded 
multipart/form-data 
text/xml 
application/json 
text/xml


226.androidstudio 升級後無法使用git svn等代碼管理工具。
vcs –>Enable Version Control Integration 選擇git/subversion 即可


227.androidstudio 升級後發現 編寫代碼自動提醒功能沒了。
原因在於打開了File—>Power Saved Mode,關閉即可。


228.dshow 音頻採集
229.kill -SIGKILL PID
強行中止(經常使用殺掉)一個進程標識號爲324的進程: 
  #kill -9 324 
  (2)解除Linux系統的死鎖 
   在Linux中有時會發生這樣一種情況:一個程序崩潰,並且處於死鎖的狀態。此時一般不用重新啓動計算機,只需要中止(或者說是關閉)這個有問題的程序 即可。當kill處於X-Window界面時,主要的程序(除了崩潰的程序之外)一般都已經正常啓動了。此時打開一個終端,在那裏中止有問題的程序。比 如,如果Mozilla瀏覽器程序出現了鎖死的情況,可以使用kill命令來中止所有包含有Mozolla瀏覽器的程序。首先用ps命令查找該程序的 PID,然後使用kill命令停止這個程序: 
  #kill -SIGKILL XXX 
  其中,XXX是包含有Mozolla瀏覽器的程序的進程標識號。 
  (3)使用命令回收內存 
  我們知道內存對於系統是非常重要的,回收內存可以提高系統資源。kill命令可以及時地中止一些”越軌”的程序或很長時間沒有相應的程序。例如,使用top命令發現一個無用(Zombie)的進程,此時可以使用下面命令: 
  #kill -9 XXX 
  其中,XXX是無用的進程標識號。 
  然後使用下面命令: 
  #free 
  此時會發現可用內存容量增加了。 
  (4)killall命令 
  Linux下還提供了一個killall命令,可以直接使用進程的名字而不是進程標識號,例如: 
  # killall -HUP inetd


230.android導入eclipse項目後,出現如下問題
1.Error:The project is using an unsupported version of the Android Gradle plug-in (0.12.2). The recommended version is 1.2.3.


classpath ‘com.android.tools.build:gradle:1.2.3’


在build.gradle 根據提示把 
dependencies { 
classpath ‘com.android.tools.build:gradle:0.12.+’ 
}


修改爲 
dependencies { 
classpath ‘com.android.tools.build:gradle:1.2.3’ 
}


2.上面修改後會出現如下錯誤:


Error:Unable to load class ‘org.codehaus.groovy.runtime.typehandling.ShortTypeHandling’.
Possible causes for this unexpected error include:You are using JDK version ‘java version “1.7.0_71”’. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle. 
Please update to a newer version (e.g. 1.7.0_67).


明明用的就是jdk1.7.0_71[比1.7.0_67還新] 卻提示不對,問題起始不在jdk這而是 gradle-wrapper.properties


distributionUrl=http://services.gradle.org/distributions/gradle-1.12-all.zip 估計用的是jdk1.7.0.10


把 distributionUrl=http://services.gradle.org/distributions/gradle-1.12-all.zip 
修改爲 distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip


ok 經過上面兩步,從studio導入eclipse項目的正常使用。


231.android 註釋模板
Settings–>Editor–>File and Code Templates–>Includes


232.shape中子節點的常用屬性
android:startColor 起始顏色 
android:endColor 結束顏色 
android:angle 漸變角度,0從上到下,90表示從左到右,數值爲45的整數倍默認爲0; 
android:type 漸變的樣式 liner線性漸變 radial環形漸變 sweep


例如:


<shape xmlns:android="http://schemas.android.com/apk/res/android"
    type="rectangle">
    <gradient
        android:angle="270"
        android:endColor="#9f36a0"
        android:startColor="#65216a" />
</shape>
2.<corners > 圓角 
android:radius 圓角的半徑 值越大角越圓


android:topRightRadius 右上圓角半徑


android:bottomLeftRadius 右下圓角角半徑


android:topLeftRadius 左上圓角半徑


android:bottomRightRadius 左下圓角半徑 
如果你把4個角設成爲90的話,那麼改圖片是一個圓! 
3.<solid > 填充 
android:color 填充的顏色


4.<stroke > 描邊 
android:width 描邊的寬度 
android:color 描邊的顏色 
android:dashWidth 表示’-‘橫線的寬度 
android:dashGap 表示’-‘橫線之間的距離


參考 http://blog.csdn.net/cs_li1126/article/details/11781577


#
233. GestureOverlayView
234.Animation lInAnim = AnimationUtils.loadAnimation(mActivity, R.anim.push_left_in);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章