在android中,当我将背景图像设置为Button时,我看不到对按钮的任何影响.我需要对按钮产生一些影响,以便用户可以识别出该按钮被单击.按钮应该是黑暗的,而在点击时几秒钟,所以我该怎么做呢?
我正在创建一个应用程序,并希望设置一个库视图.我不希望图库视图中的图像为完整大小.如何在Android中调整图像大小?
我想在屏幕上显示图像.图像应来自URL,而不是可绘制的.
代码在这里:
<ImageView android:id="@+id/ImageView01" android:src = "http://l.yimg.com/a/i/us/we/52/21.gif"
android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
Run Code Online (Sandbox Code Playgroud)
但它在编译时出错.
如何在Android中显示来自URL的图像?
在给定的代码中lbl [0] .getTextColor()给出了Error,但我不知道如何在java文件中获取textview的文本颜色请帮帮我.
public void angry(View v)
{
if (lbl[0].getTextColor() == Color.BLACK)
lbl[0].setTextColor(Color.RED);
if (lbl[0].getTextColor() == Color.RED)
lbl[0].setTextColor(Color.BLACK);
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
当我从一个活动移动到另一个活动时,我想从左到右实现滑动效果.为此,我使用以下代码,但我没有得到任何结果.请指正.
在java这两个文件中:
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
setContentView(R.layout.main);
Run Code Online (Sandbox Code Playgroud)
res/anim目录中的两个文件:
fadein.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="5000"
android:fromAlpha="0.0"
android:interpolator="@android:anim/slide_out_right"
android:toAlpha="1.0" >
</alpha>
Run Code Online (Sandbox Code Playgroud)
fadeout.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="5000"
android:fromAlpha="0.0"
android:interpolator="@android:anim/slide_in_left"
android:toAlpha="1.0" >
</alpha>
Run Code Online (Sandbox Code Playgroud) 我想要这样的验证,My String必须至少包含一个字母.
我使用以下内容:
String s = "111a11";
boolean flag = s.matches("%[a-zA-Z]%");
Run Code Online (Sandbox Code Playgroud)
false 即使a在我的字符串中,flag 也会给我s
我正在尝试使用此代码邮寄数据:
email = (Button) findViewById(R.id.enail);
email.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
emailIntent.setAction(Intent.ACTION_SEND);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { "" });
emailIntent.putExtra(android.content.Intent.EXTRA_CC, "");
emailIntent.putExtra(android.content.Intent.EXTRA_BCC, "");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Playlist Details");
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(Detail));
emailIntent.setType("text/html");
startActivity(emailIntent);
}
});
Run Code Online (Sandbox Code Playgroud)
但它会引发以下错误:
07-17 12:31:33.438: E/AndroidRuntime(498): FATAL EXCEPTION: main
07-17 12:31:33.438: E/AndroidRuntime(498): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND (has extras) }
07-17 12:31:33.438: E/AndroidRuntime(498): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
07-17 12:31:33.438: E/AndroidRuntime(498): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
07-17 12:31:33.438: E/AndroidRuntime(498): at android.app.Activity.startActivityForResult(Activity.java:2817)
07-17 12:31:33.438: E/AndroidRuntime(498): …Run Code Online (Sandbox Code Playgroud) 我正在创建一个Android应用程序,我正在使用sqlite数据库.因为我已经在项目的资产文件夹中放置了一个sqlite文件,我在使用下面的代码首次执行应用程序时将此文件复制到手机.
private void copyDataBase() throws IOException {
new File(DB_PATH).mkdirs();
InputStream myInput = appContext.getAssets().open(DB_NAME);
String outFileName = DB_PATH + DB_NAME;
OutputStream myOutput = new FileOutputStream(outFileName);
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0) {
myOutput.write(buffer, 0, length);
}
myOutput.flush();
myOutput.close();
myInput.close();
}
Run Code Online (Sandbox Code Playgroud)
但我得到了这个错误.
09-21 18:03:56.841: E/SQLiteLog(7850): (1) no such table: tbl_player
Run Code Online (Sandbox Code Playgroud)
但是这个表存在于资产文件中.所以我使用这种方法从手机中获取数据库文件.
public static void exportDB(String databaseName, Context context) {
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = …Run Code Online (Sandbox Code Playgroud) 我正在使用ActionBarSherlock并且我试图隐藏我的应用程序的标题栏但是每当我这样做时,我NullPointerException在访问" ActionBar如何删除/隐藏标题栏" 时会得到一个?请注意,我不是指操作栏的标题.我指的是操作栏上方的标题栏.我在Android 2.3设备上运行我的应用程序.
下面是我的代码:(我的课程延伸SherlockFragmentActivity.)
super.onCreate(savedInstanceState);
setTheme(R.style.Theme_Sherlock);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
ActionBar actionbar = getSupportActionBar();
actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //I get the NullPointerException here.
//...
setContentView(R.layout.tab_navigation);
Run Code Online (Sandbox Code Playgroud)