我需要在Android UI中绘制一个圆角矩形.具有相同的圆角矩形TextView
,并EditText
也将是有益的.
我的代码中有一个文件名:
String NAME_OF_FILE="//sdcard//imageq.png";
FileInputStream fis =this.openFileInput(NAME_OF_FILE); // 2nd line
Run Code Online (Sandbox Code Playgroud)
我在第二行收到错误:
05-11 16:49:06.355:ERROR/AndroidRuntime(4570):引起:java.lang.IllegalArgumentException:文件//sdcard//imageq.png包含路径分隔符
我也试过这种格式:
String NAME_OF_FILE="/sdcard/imageq.png";
Run Code Online (Sandbox Code Playgroud) 在我的媒体播放器中,我从sdcard播放一首歌.它显示错误为NullPointerException:println在android中需要一条消息e.我试了很久但我不知道原因.请帮助我.
码:
try {
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource("/sdcard/t1.mp3");
seek.setMax(mediaPlayer.getDuration());
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(this);
}
catch(Exception ex){
Log.e("sdcard-err2:",ex.getMessage()); // null pointer exception : println needs a message
}
Run Code Online (Sandbox Code Playgroud)
原木猫:
05-16 19:27:54.491: ERROR/AndroidRuntime(6889): Caused by: java.lang.NullPointerException: println needs a message
05-16 19:27:54.491: ERROR/AndroidRuntime(6889): at android.util.Log.println(Native Method)
05-16 19:27:54.491: ERROR/AndroidRuntime(6889): at android.util.Log.e(Log.java:208)
05-16 19:27:54.491: ERROR/AndroidRuntime(6889): at com.seek.bar.media3.onCreate(media3.java:43)
05-16 19:27:54.491: ERROR/AndroidRuntime(6889): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-16 19:27:54.491: ERROR/AndroidRuntime(6889): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
05-16 19:27:54.491: ERROR/AndroidRuntime(6889): ... 11 more
Run Code Online (Sandbox Code Playgroud) 我需要在文本字段下面绘制一条水平线,使得线条的宽度等于文本宽度(而不是整个屏幕的宽度).
在我的应用程序中,我在视图下方有一个textview(水平线).的线视图的宽度应等于TextView的的宽度.我试过android:layout_width ="wrap_content"和"match_parent",但这并没有解决问题.
这是xml编码示例:
......
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp"
android:text="PopUpWindow"
android:textAppearance="?android:attr/textAppearanceLarge" />
<View
android:id="@+id/separator"
android:layout_width="wrap_content"
android:layout_height="0.3dp"
android:layout_below="@+id/textView1"
android:background="#ffffff" />
......
Run Code Online (Sandbox Code Playgroud)
屏幕的图像是:
请帮我.
在Eclipse中构建Android项目时,Android SDK会出现如下错误:
错误:
Description Resource Path Location Type
1) Error generating final archive: Debug Certificate expired on 7/9/11 6:31 PM MapByLocation Unknown Android Packaging Problem
2)Error generating final archive: Debug Certificate expired on 7/9/11 6:31 PM PageCurlAnimation Unknown Android Packaging Problem
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么解决.请帮我.
在我的Android应用程序中,我使用的是okHttp库.如何使用okhttp库将参数发送到服务器(api)?目前我使用以下代码访问服务器现在需要使用okhttp库.
这是我的代码:
httpPost = new HttpPost("http://xxx.xxx.xxx.xx/user/login.json");
nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("email".trim(), emailID));
nameValuePairs.add(new BasicNameValuePair("password".trim(), passWord));
httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
String response = new DefaultHttpClient().execute(httpPost, new BasicResponseHandler());
Run Code Online (Sandbox Code Playgroud) 我需要在走路时不计算步数.所以我正在使用加速度计.在上面的编码中,我得到了加速计传感器的x,y,z值.这是我到目前为止所做的.我的问题是由x,y,z如何计算步行时的步数?我从链接中获取以下代码
http://pedometer.googlecode.com/svn/trunk/src/name/bagi/levente/pedometer/Pedometer.java
我的代码:
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class Accelerometer extends Activity implements AccelerometerListener {
private static Context CONTEXT;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
CONTEXT = this;
}
protected void onResume() {
super.onResume();
if (AccelerometerManager.isSupported()) {
AccelerometerManager.startListening(this);
}
}
protected void onDestroy() {
super.onDestroy();
if (AccelerometerManager.isListening()) {
AccelerometerManager.stopListening();
}
}
public static Context getContext() {
return CONTEXT;
}
/**
* onShake callback …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从 Github 克隆存储库,但无法克隆该存储库,它因 TLS 证书验证已被禁用而失败!错误。
当我运行 git clone 命令时,它会重定向到在 Github 上登录,但 TLS 证书失败,并且存储库身份验证失败,即使输入有效的凭据也是如此。
我的 Github 帐户启用了双因素身份验证。
我尝试过禁用 sslverifcation 也 git config --global http.sslVerify false
系统规格:
操作系统:Windows 10
架构:64位
请帮我解决这个问题。提前致谢。
如何设置setLayoutParams()
的LinearLayout
元素.在MainActivity.java
.我为set layout params编写了以下代码,并nullPointerException
在第50行显示,最后我粘贴了Logcat文件.
layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 50);
imageview1.setLayoutParams(layoutParams); // line no 50
layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 50);
textview1.setLayoutParams(layoutParams);
layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
listview01.setLayoutParams(layoutParams);
Run Code Online (Sandbox Code Playgroud)
这是我的xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stackFromBottom="true"
>
<ImageView
android:id="@+id/imageview1"
android:layout_width="wrap_content"
android:layout_height="50px"
android:background="@drawable/applicationbar"
android:layout_x="0px"
android:layout_y="0px"
>
</ImageView>
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="50px"
android:text="TextView"
android:layout_x="0px"
android:layout_y="55px"
>
</TextView>
<ListView android:id="@+id/ListView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10px"
android:layout_marginRight="10px"
android:layout_marginTop="35px"
android:layout_marginBottom="40px"
android:paddingLeft="0px"
android:paddingRight="0px" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
原木猫:
04-19 16:47:22.221: ERROR/AndroidRuntime(3437): Uncaught handler: thread …
Run Code Online (Sandbox Code Playgroud)