我有一个非常简单的RelativeLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frag"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/listApplications"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<!-- AD SERVER -->
<ImageView
android:id="@+id/ad_server_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="0dp"
android:contentDescription="@string/ad_banner_image_description"
android:gravity="bottom|center_horizontal"
android:paddingBottom="0dp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
ImageView与其父级(RelativeLayout)的底部对齐,我将填充/边距设置为0,但我在图像的顶部和底部得到一个白色的"边框"(请参阅红色标记):

谢谢 !
如果选择了第一个元素,我想更新ArrayAdapter的值:
public ArrayAdapter<String> adapter;
String[] categoriesArray;
...
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, categoriesArray);
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
if(arg2== Consts.GAME_CATEGORY_POSITION){
adapter.clear();
//Add new values to array
categoriesArray = new String[subCategories.size()];
for (int i=0; i<subCategories.size(); i++) {
categoriesArray[i] = subCategories.get(i).getSub_name();
}
adapter.notifyDataSetChanged();
}
}
});
Run Code Online (Sandbox Code Playgroud)
但是clear方法(适配器)触发了异常
12-27 09:37:57.376: E/AndroidRuntime(1423): java.lang.UnsupportedOperationException
12-27 09:37:57.376: E/AndroidRuntime(1423): at java.util.AbstractList.remove(AbstractList.java:638)
12-27 09:37:57.376: E/AndroidRuntime(1423): at java.util.AbstractList$SimpleListIterator.remove(AbstractList.java:75)
12-27 09:37:57.376: E/AndroidRuntime(1423): at java.util.AbstractList.removeRange(AbstractList.java:658)
12-27 09:37:57.376: E/AndroidRuntime(1423): at java.util.AbstractList.clear(AbstractList.java:466)
12-27 …Run Code Online (Sandbox Code Playgroud) 我想用RSA加密对String进行加密。我的公钥/私钥已生成并存储在DB中。在android中,我使用以下代码:
public static String encryptRSAToString(String text, String strPublicKey) {
byte[] cipherText = null;
String strEncryInfoData="";
try {
KeyFactory keyFac = KeyFactory.getInstance("RSA");
KeySpec keySpec = new X509EncodedKeySpec(Base64.decode(strPublicKey.trim().getBytes(), Base64.DEFAULT));
Key publicKey = keyFac.generatePublic(keySpec);
// get an RSA cipher object and print the provider
final Cipher cipher = Cipher.getInstance("RSA");
// encrypt the plain text using the public key
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
cipherText = cipher.doFinal(text.getBytes());
strEncryInfoData = new String(Base64.encode(cipherText,Base64.DEFAULT));
} catch (Exception e) {
e.printStackTrace();
}
return strEncryInfoData.replaceAll("(\\r|\\n)", "");
}
Run Code Online (Sandbox Code Playgroud)
出于调试目的,我尝试使用相同的参数调用此方法两次,并且String结果相似(符合预期)。
我想在Java中生成相同的加密字符串。但是,“ android.util.Base64”类在Java中不可用,因此我尝试使用默认的Base64类:
public static …Run Code Online (Sandbox Code Playgroud) 我的proguard和Gson库有问题.我的代码是
AdServerResult result = (AdServerResult) new Gson().fromJson(json,
AdServerResult.class);
Run Code Online (Sandbox Code Playgroud)
(我AdServerResult使用Gson库创建一个新对象)
我的AdServerResult班级:
public class AdServerResult {
public ArrayList<AdServerObject> shorts ;
public ArrayList<AdServerObject> longs ;
public ArrayList<AdServerObject> getShorts() {
return shorts;
}
public void setShorts(ArrayList<AdServerObject> shorts) {
this.shorts = shorts;
}
public ArrayList<AdServerObject> getLongs() {
return longs;
}
public void setLongs(ArrayList<AdServerObject> longs) {
this.longs = longs;
}
//for debug
@Override
public String toString(){
StringBuilder sb = new StringBuilder() ;
if (shorts!=null && shorts.size()>0){
for (AdServerObject s: shorts){
sb.append("url: "+s.getPicture_url()); …Run Code Online (Sandbox Code Playgroud)