如何为线性布局显示阴影.我想要白色圆形背景和线性布局周围的阴影.到目前为止我已经这样做了.请帮我.提前致谢.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@xml/rounded_rect_shape"
android:orientation="vertical"
android:padding="10dp">
<-- My buttons, textviews, Imageviews go here -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
和xml目录下的rounded_rect_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffffff" />
<corners
android:bottomLeftRadius="3dp"
android:bottomRightRadius="3dp"
android:topLeftRadius="3dp"
android:topRightRadius="3dp" />
</shape>
Run Code Online (Sandbox Code Playgroud) 我想从java代码登录应用程序.这是我的代码......
String httpsURL = "https://www.abcd.com/auth/login/";
String query = "email="+URLEncoder.encode("abc@xyz.com","UTF-8");
query += "&";
query += "password="+URLEncoder.encode("abcd","UTF-8") ;
URL myurl = new URL(httpsURL);
HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-length", String.valueOf(query.length()));
con.setRequestProperty("Content-Type","application/x-www- form-urlencoded");
con.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0;Windows98;DigExt)");
con.setDoOutput(true);
con.setDoInput(true);
DataOutputStream output = new DataOutputStream(con.getOutputStream());
output.writeBytes(query);
output.close();
DataInputStream input = new DataInputStream( con.getInputStream() );
for( int c = input.read(); c != -1; c = input.read() )
System.out.print( (char)c );
input.close();
System.out.println("Resp Code:"+con .getResponseCode());
System.out.println("Resp Message:"+ con .getResponseMessage());
Run Code Online (Sandbox Code Playgroud)
但我无法登录,它只返回登录页面.
如果有人可以,请帮助我理解我做错了什么.
我的应用程序使用简单的Facebook登录.我已经在我的应用仪表板,key_hash部分输入了keyhash,我能够成功登录.现在我已经发布了应用程序并尝试登录,但是它在webview上显示错误消息
"Invalid android_key parameter. The key rX6qeRitkFCWui3de74rxB_qc1s does not match any allowed key. Configure your app key hashes at http://developers.facebook.com/apps/<my_fb_app_id>".
Run Code Online (Sandbox Code Playgroud)
实际上rX6qeRitkFCWui3de74rxB_qc1s不是我在本机应用程序中的密钥哈希.它来自哪里?无论如何,我也在本机应用程序中输入了此键盘,但收到相同的错误消息,无法登录.哪里出错了?请帮我.
以下是我如何启动原生谷歌地图应用以显示我和目标位置之间的路线.
String url = "http://maps.google.com/maps?saddr="+currentLattitude+","+currentLongitude+"&daddr="+targetLat+","+targetLang;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
有没有办法启动原生地图应用程序来显示驾驶和运输模式?(目前仅展示行走方向)
我必须定期向服务器发送我当前的位置详细信息(lat和long)(例如:每5分钟一次).有什么最好的方法吗?我知道如何获取当前位置以及如何将详细信息发送到服务器.但是我该如何定期重复这个?
我需要发布JSONObject(使用Volley)一个以JSONArray格式返回响应的Web服务.
这是我到目前为止所尝试的.
final JSONObject requestJsonObject = new JSONObject();
requestJsonObject.put("username", userName);
requestJsonObject.put("password", password);
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.POST, ServiceUrls.LOGIN_URL, requestJsonObject, loginResponseListener, loginErrorListener);
private Listener<JSONObject> loginResponseListener = new Listener<JSONObject>() {
@Override
public void onResponse(JSONObject resposne) {
//other stuff goes here
}
};
Run Code Online (Sandbox Code Playgroud)
但我JSONException要说的是JSONArray无法转换为JSONObject.有没有办法以JSONArray格式获得响应?什么是我的问题的最佳解决方案?JSONObject如果我使用StringRequest而不是,我该如何发送JsonObjectRequest?请指导我
我点击按钮打开相机应用程序.并在下一个活动中显示捕获的照片.但捕获的照片旋转了90度.当我捕捉到图像后在视图中显示图像时,它的方向始终是横向的.为什么在纵向模式下拍摄照片时,照片不会以纵向显示?
点击按钮:
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(APP_DIR+"/latest.png")));
startActivityForResult(i, CAPTURE_PHOTO_CONSTANT);
Run Code Online (Sandbox Code Playgroud)
在onActvityresult里面:
bmp = BitmapFactory.decodeFile(APP_DIR+"/latest.png");
startActivity(new Intent(this, DisplayActivity.class));
Run Code Online (Sandbox Code Playgroud)
显示拍摄的照片:
photoViewRelativeLayout.setBackgroundDrawable(new BitmapDrawable(getResources(), CaptureActivity.bmp));
Run Code Online (Sandbox Code Playgroud) 这是我的代码,用于将数据存储到HashMap中并使用迭代器显示数据
public static void main(String args[]) {
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("aaa", "111");
hm.put("bbb", "222");
hm.put("ccc", "333");
hm.put("ddd", "444");
hm.put("eee", "555");
hm.put("fff", "666");
Iterator iterator = hm.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
String val = hm.get(key);
System.out.println(key + " " + val);
}
}
Run Code Online (Sandbox Code Playgroud)
但它没有按照我存储的顺序显示.有人可以告诉我哪里出错了吗?我怎样才能获得订单中的元素?
为什么只有ListView可见?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ListView android:id="@+id/android:list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_gravity="center" android:choiceMode="singleChoice">
</ListView>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="15dp">
<Button android:id="@+id/viewComplaintsMoreButton"
android:text=" More "
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<Button android:id="@+id/viewComplaintsCancelButton"
android:text=" Cancel "
android:layout_marginLeft="50dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)