我正在使用bitbucket,所以我可以与其他开发人员合作,但似乎我们无法让它完美地工作.从他那里取消后我得到了这个错误:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
E:\Program Files (x86)\Android\android-sdk\build-tools\19.0.0\aapt.exe package -f --no-crunch -I E:\Program Files (x86)\Android\android-sdk\platforms\android-19\android.jar -M E:\Documents\smart-my-job1\app\build\manifests\debug\AndroidManifest.xml -S E:\Documents\smart-my-job1\app\build\res\all\debug -A E:\Documents\smart-my-job1\app\build\assets\debug -m -J E:\Documents\smart-my-job1\app\build\source\r\debug -F E:\Documents\smart-my-job1\app\build\libs\app-debug.ap_ --debug-mode --custom-package com.smartmyjob
Error Code:
-1073741819
Run Code Online (Sandbox Code Playgroud) 我习惯将库导入为.jar文件,但我不知道如何使用github中的项目,如下所示:https://github.com/jfeinstein10/SlidingMenu/
我想在我现有的项目中使用它.我尝试将项目文件包含在依赖项中,但它给了我一些错误
我在scrollview中有一个相对布局,我无法让它工作.我尝试将相对布局的高度设置为wrap_content,但它也不起作用.我可以使用线性布局,但我不想出于某种原因使用它.
这是我的xml:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical"
android:padding="14dp">
<EditText
android:layout_width="match_parent"
android:layout_height="48dp"
android:inputType="textPersonName"
android:id="@id/feedback_name"
android:hint="Name"
android:textColor="#000000"
android:layout_alignParentTop="true"
android:ems="10"
android:maxHeight="48dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="48dp"
android:inputType="textEmailAddress"
android:ems="10"
android:maxHeight="48dp"
android:id="@id/feedback_email"
android:hint="Your email (optional)"
android:textColor="#000000"
android:layout_below="@id/feedback_name"
android:textSize="14sp" />
<Spinner
android:id="@id/feedback_concern"
android:layout_width="match_parent"
android:layout_height="48dp"
android:minHeight="48dp"
android:layout_below="@id/feedback_email" />
<EditText
android:layout_width="match_parent"
android:layout_height="0dp"
android:inputType="textMultiLine"
android:ems="10"
android:id="@id/feedback_message"
android:hint="Message"
android:textColor="#000000"
android:layout_weight="1"
android:minHeight="70dp"
android:gravity="top"
android:textSize="14sp"
android:layout_below="@id/feedback_concern"
android:layout_above="@id/feedback_send"
/>
<Button
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="Send"
android:maxHeight="48dp"
android:id="@id/feedback_send"
android:background="@color/light"
android:textColor="#FFFFFF"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:visibility="invisible"
android:layout_gravity="center_horizontal" …Run Code Online (Sandbox Code Playgroud) 我有一个viewpager,可以保存Nostra的Universal Image Loader加载的图像.此viewpager也是listview的一部分,作为标题.将高度设置为wrap_content不起作用,它只显示任何内容,但如果我将其设置为特定的dip,则可以正常工作.我的怀疑是,viewpager在加载图像之前将其内容包装起来,因此它不会显示任何内容.
这是布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp">
<android.support.v4.view.ViewPager
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@id/viewpager"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<com.sblive.other.CirclePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginBottom="3dp"
android:layout_gravity="center_horizontal|bottom"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerHorizontal="true"/>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
ViewPager的PagerAdapter的一部分:
@Override
public Object instantiateItem(ViewGroup container, int position) {
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.header_item, container,false);
ImageView img = (ImageView) itemView.findViewById(R.id.imageView);
ProgressBar progressBar = (ProgressBar) itemView.findViewById(R.id.progressBar);
display(img, list.get(position), progressBar);
((ViewPager) container).addView(itemView);
return itemView;
}
Run Code Online (Sandbox Code Playgroud) 我按照本教程加密和解密android/java中的简单字符串:
/sf/ask/302364751/ 我做了一个Cryptography类:
public class Cryptography {
public static SecretKey generateKey() throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("SHA");
digest.update("BhLKTyLoP YroUsRQT".getBytes());
return new SecretKeySpec(digest.digest(), 0, 16, "AES");
}
public static byte[] encrypt(String message, SecretKey key) throws NoSuchAlgorithmException, BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException, UnsupportedEncodingException {
Cipher aes = Cipher.getInstance("AES/ECB/PKCS5Padding");
aes.init(Cipher.ENCRYPT_MODE, key);
return aes.doFinal(message.getBytes());
}
public static String decrypt(byte[] cipherText, SecretKey key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
Cipher aes = Cipher.getInstance("AES/ECB/PKCS5Padding");
aes.init(Cipher.DECRYPT_MODE, key);
return new String(aes.doFinal(cipherText));
}
}
Run Code Online (Sandbox Code Playgroud)
我能够加密方法并给了我这个:
Encrypted username: [B@52aff408 …Run Code Online (Sandbox Code Playgroud) 这是我第一次使用Java的Pattern类,因为我想检查字符串是否为大写.特殊符号如"." 和","应被视为大写.以下是预期结果:
"test,." should return false //because it has a lowercase character
"TEST,." should return true //because all are uppercase and the special characters
"test" should return false //because it has a lowercase character
"TEST" should return true //because all are uppercase
"teST" should return false //because it has a lowercase character
Run Code Online (Sandbox Code Playgroud)
我试图使用apache的StringUtils,但它不能这样工作..
我尝试在我的单例类中设置我的asynchttpclient的超时,但似乎它没有改变.我得到10000,我认为是默认值.
client.setMaxRetriesAndTimeout(0,5000);
Log.i("loopj", ""+ client.getTimeout());
Run Code Online (Sandbox Code Playgroud)
编辑:
client.setTimeout(5000);
Run Code Online (Sandbox Code Playgroud)
这个方法工作但是对于信息,setMaxRetriesAndTimeout怎么没有?
我尝试用scrollview包装我的relativelayout以在横向模式下使用但它不起作用.我也尝试用linearlayout包装我的相对布局,但它也不起作用.
这是xml,其中relativelayout包含在scrollview中:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2d89ef">
<!--Some components here-->
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
这是我的完整xml:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2d89ef">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="Segoe UI Light"
android:gravity="center"
android:text="@string/app_name"
android:textColor="#FFFFFF"
android:textSize="25dp"
android:textIsSelectable="false"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<EditText
android:id="@+id/editText"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="Segoe UI Light"
android:gravity="center_vertical"
android:hint="@string/username"
android:inputType="textPersonName"
android:textColor="@android:color/white"
android:textSize="16sp"
android:width="200dp"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true">
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="Segoe UI Light"
android:gravity="center_vertical"
android:hint="@string/password"
android:inputType="textPassword"
android:textColor="@android:color/white"
android:textSize="16sp"
android:width="200dp"
android:layout_below="@+id/editText"
android:layout_alignRight="@+id/editText"
android:layout_alignLeft="@+id/editText" /> …Run Code Online (Sandbox Code Playgroud) 我发现当我按下设备上的菜单按钮时,它会给我一个NullPointerException.
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu); //NullPointer Here
return true;
}
Run Code Online (Sandbox Code Playgroud)
所以我做的是通过删除上面的第二行并将返回类型更改为false来完全禁用菜单.但是,它仍然给我一个NullPointerException.这是堆栈:
11-25 03:50:20.931 1212-1212/com.sblive.aufschoolbliz E/InputEventSender? Exception dispatching finished signal.
11-25 03:50:20.931 1212-1212/com.sblive.aufschoolbliz E/MessageQueue-JNI? Exception in MessageQueue callback: handleReceiveCallback
11-25 03:50:21.040 1212-1212/com.sblive.aufschoolbliz E/MessageQueue-JNI? java.lang.NullPointerException
at android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:274)
at android.support.v7.app.ActionBarActivityDelegate.getMenuInflater(ActionBarActivityDelegate.java:89)
at android.support.v7.app.ActionBarActivity.getMenuInflater(ActionBarActivity.java:71)
at android.app.Activity.onCreatePanelMenu(Activity.java:2505)
at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:224)
at android.support.v7.app.ActionBarActivity.superOnCreatePanelMenu(ActionBarActivity.java:224)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreatePanelMenu(ActionBarActivityDelegateICS.java:141)
at android.support.v7.app.ActionBarActivity.onCreatePanelMenu(ActionBarActivity.java:199)
at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onCreatePanelMenu(ActionBarActivityDelegateICS.java:280)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:413)
at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:795)
at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1471)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1867)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3791)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3774)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379) …Run Code Online (Sandbox Code Playgroud) 我的任务是制作1-10的乘法表,但我对我的代码不满意,似乎很长:
for (int i = 1; i <= 10; i++)
{
System.out.println("1x" + i + " = " + i + "\t" + "2x" + i + " = " + (2*i)
+ "\t" + "3x" + i + " = " + (3*i) + "\t" + "4x" + i + " = " + (4*i)
+ "\t" + "5x" + i + " = " + (5*i) + "\t" + "6x" + i + " = " + (6*i) …Run Code Online (Sandbox Code Playgroud) 我正在从一个网站解析一个json并尝试从中获取一些数据.但是,它在迭代对象集合时给出了未定义的值.如果它是一个格式错误的json,不幸的是,我无法改变它.
[
{
"startYear": 2014,
"startMonth": 6,
"startDay": 31,
"endYear": 2014,
"endMonth": 7,
"endDay": 29,
"selectedDate": "2014_7_8",
"departureStation": "Manila",
"arrivalStation": "Boracay (Caticlan)",
"departureStationCode": "(MNL)",
"arrivalStationCode": "(MPH)",
"departureLabel": "DEPARTURE",
"arrivalLabel": "RETURN",
"dateMarketHash": {
"date_0_2014_6_31": {
"containerId": "date_0_2014_6_31",
"fromLabel": "From",
"currency": "PHP",
"price": null,
"formattedDate": "Thu, Jul 31, 2014",
"year": "2014",
"month": "6",
"day": "31",
"points": null,
"pointsSuffix": "",
"pointsLabelAppend": ""
},
"date_0_2014_7_1": {
"containerId": "date_0_2014_7_1",
"fromLabel": "From",
"currency": "PHP",
"price": 1929,
"formattedDate": "Fri, Aug 01, 2014",
"year": "2014",
"month": "7",
"day": …Run Code Online (Sandbox Code Playgroud) android ×7
java ×4
scrollview ×2
bitbucket ×1
cryptography ×1
encryption ×1
github ×1
javascript ×1
json ×1
loops ×1
regex ×1