我正在开发一些应用程序,它允许从SD卡中选择图像,将其保存到数据库中并为ImageView设置此值.我需要知道将uri转换为字符串和字符串转换为uri的方法.现在我使用了Uri的getEncodedPath()方法,但是,例如,这段代码不起作用:
ImageView iv=(ImageView)findViewById(R.id.imageView1);
Uri uri=Uri.parse("/external/images/media/470939");
Log.e("uri1", uri.toString());
iv.setImageURI(uri);
Run Code Online (Sandbox Code Playgroud)
因此,我不知道如何将Uri保存到数据库中并从保存的值创建新的Uri.请帮我修理一下.
有以下Java代码:
public static void register(UserInfo info) throws ClientProtocolException, IOException, JSONException, RegistrationException {
List<NameValuePair> params=new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name", info.getName()));
params.add(new BasicNameValuePair("email", info.getEmail()));
params.add(new BasicNameValuePair("pass", info.getPassword()));
params.add(new BasicNameValuePair("genus", String.valueOf(info.getGenus())));
String response=doPostRequest(params, REGISTRATION_URL);
}
private static String doPostRequest(List<NameValuePair> params, String url) throws ClientProtocolException, IOException {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
httppost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse response = httpclient.execute(httppost);
return getContentFromInputStream(response.getEntity().getContent());
}
private static String getContentFromInputStream(InputStream is) throws IOException {
String line;
StringBuilder sb=new StringBuilder();
BufferedReader reader=new BufferedReader(new InputStreamReader(is));
while((line=reader.readLine())!=null) { …Run Code Online (Sandbox Code Playgroud) 我有以下HTML代码:
<div id="footer">
<ul id="yw1">
<li><a href="/index.php/site/login">About</a></li>
<li><a href="/index.php/site/login">FAQ</a></li>
<li><a href="http://twitter.com"><img src="/images/twitter_icon.png" /></a></li>
<li><a href="http://twitter.com"><img src="/images/facebook_icon.png" /></a></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
以下CSS样式:
#footer {
margin-top: 25px;
background: #000000 url(images/background.png) repeat;
padding: 25px;
box-shadow: 0px 0px 10px 5px rgba(0, 0, 0, .2);
}
#footer ul {
margin: 0;
padding: 0px 0px 0px 0px;
list-style: none;
line-height: normal;
}
#footer li {
padding-left: 20px;
display: inline;
list-style-type: none;
}
#footer a {
color:white;
letter-spacing: 1px;
text-decoration: none;
text-align: center;
font-size: 14px;
font-weight: 300;
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试为ListView设置长按侦听器:
final ListView gallery=(ListView)findViewById(R.id.dialogViewImagesList);
gallery.setLongClickable(true);
gallery.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
Log.e("event", "long");
return true;
}
});
gallery.setAdapter(new PointImagesAdapter(bitmaps));
Run Code Online (Sandbox Code Playgroud)
这是我的适配器:
private class PointImagesAdapter extends ArrayAdapter<Bitmap> {
private static final int LAYOUT_ID=R.layout.adapter_point_images;
private List<Bitmap> bitmaps;
private LayoutInflater inflater;
public PointImagesAdapter(List<Bitmap> bitmaps) {
super(MainActivity.this, LAYOUT_ID, bitmaps);
this.bitmaps=bitmaps;
inflater=LayoutInflater.from(MainActivity.this);
}
@Override
public View getView(int position, View view, ViewGroup group) {
if (view==null) {
view=inflater.inflate(LAYOUT_ID, null);
}
ImageView i=(ImageView)view.findViewById(R.id.adapterPointImagesItem);
i.setScaleType(ImageView.ScaleType.CENTER);
i.setImageBitmap(bitmaps.get(position));
view.setFocusable(false);
return view;
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试过设置view.setLongClickable(true),但在这种情况下,ListView项目不可点击(简单点击不起作用).它是适配器的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout …Run Code Online (Sandbox Code Playgroud) 我是CSS的新手,我有一个问题.我想制作一个简单的简单表格,并且有以下代码:
<form>
<div class="row"><label for="name">Some text field</label><input type="text" name="name" /></div>
<div class="row"><label for="surname">Some another text field</label><input type="text" name="surname" /></div>
</form>
Run Code Online (Sandbox Code Playgroud)
一些CSS代码:
label {
float: left;
width: 230px;
text-align: right;
margin: 5px;
}
.row {
clear: left;
}
Run Code Online (Sandbox Code Playgroud)
我从一本书中复制并粘贴了这段代码.我理解浮动,清除,但我不明白为什么"width"属性与label一起使用(因为它是内联元素),在这种情况下,为什么"width"不能在没有"float"的情况下工作?请让我说清楚.谢谢