我看到了很多好的旧有用的方法,甚至整个类都被"弃用和过时".
但是用于调用这些方法的代码仍然有效.那么,作为Android应用程序开发人员,这对我意味着什么呢?
当没有提供替代方案时,这尤其令人困惑,例如WebView.PictureListener.html#onNewPicture.
我是junit测试的新手.
任何人都可以帮助我,如何测试我的SQLiteOpenHelper课程.
意味着我必须实现哪些类以及如何测试我的数据库和表.我正在使用Eclipse IDE.
在Android中是否有任何方法(据我所知)没有java.text.Normalizer,从String中删除任何重音.例如"éàù"变成"eau".
如果可能的话,我想避免解析String来检查每个字符!
我想做什么:包含这样的消息的列表:
<UserName>,这是用户编写的mnessage,它将很好地包装到下一行.完全是这样的.
是)我有的:
ListView R.layout.list_item:
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_message"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="(Message Text)" />
Run Code Online (Sandbox Code Playgroud)
膨胀以上布局的适配器并执行:
SpannableStringBuilder f = new SpannableStringBuilder(check.getContent());
f.append(username);
f.setSpan(new InternalURLSpan(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context, "Clicked User", Toast.LENGTH_SHORT).show();
}
}), f.length() - username.length(), f.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
f.append(" " + message);
messageTextView.setText(f);
messageTextView.setMovementMethod(LinkMovementMethod.getInstance());
meesageTextView.setFocusable(false);
Run Code Online (Sandbox Code Playgroud)
InternalURLSpan类
public class InternalURLSpan extends ClickableSpan {
OnClickListener mListener;
public InternalURLSpan(OnClickListener listener) {
mListener = listener;
}
@Override
public void onClick(View widget) {
mListener.onClick(widget);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds); …Run Code Online (Sandbox Code Playgroud) 我需要使用视频作为我的背景.首先,我将视频文件放在drawable文件夹中,并LinearLayout在main.xml中作为后台调用.但在运行应用程序时,我只看到了黑屏.然后我尝试使用VideoView并调用它如下:
<VideoView
android:id="@+id/video"
android:layout_width="320px"
android:layout_height="240px"
android:layout_gravity="center"
android:background="@raw/hp"/>
Run Code Online (Sandbox Code Playgroud)
在我的活动文件中,我使用以下代码片段调用它:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView video=(VideoView) findViewById(R.id.video);
video.start();
}
Run Code Online (Sandbox Code Playgroud)
但我仍然没有收到视频文件.我的主要建议是使用气泡视频作为背景,并在其上放置两个气泡按钮,让用户感觉像水景屏幕.谁能帮我?
我想从res文件夹中使用的视频文件.不是来自SD卡或任何外部媒体文件夹.
请在下面找到我的代码.我需要获取用户从SDcard中选择的pdf文档的文件路径.问题是URI.getPath()返回:
/file:///mnt/sdcard/my%20Report.pdf/my Report.pdf
Run Code Online (Sandbox Code Playgroud)
正确的道路是:
/sdcard/my Report.pdf
Run Code Online (Sandbox Code Playgroud)
请注意我在stackoverflow上搜索但是找到了获取图像或视频的filePath的示例,在PDF的情况下没有如何获取文件路径的示例?
我的代码,不是所有代码,只有pdf部分:
public void openPDF(View v)
{
Intent intent = new Intent();
//intent.setType("pdf/*");
intent.setType("application/pdf");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Pdf"), SELECT_PDF_DIALOG);
}
public void onActivityResult(int requestCode, int resultCode, Intent result)
{
if (resultCode == RESULT_OK)
{
if (requestCode == SELECT_PDF_DIALOG)
{
Uri data = result.getData();
if(data.getLastPathSegment().endsWith("pdf"))
{
String pdfPath = data.getPath();
}
else
{
CommonMethods.ShowMessageBox(CraneTrackActivity.this, "Invalid file type");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我如何从URI获取正确的路径?
我想知道android SeekBars OnSeekBarChangeListener的行为.特别是onProgressChanged方法是否仅针对搜索栏上的第一次和最后一次触摸进行通知?
我正在尝试刷新应该显示SeekBar当前进度的TextView.但TextView只是在第一次触摸和最后一次触摸时更新.调试这证实了我的假设,这个方法被调用两次:(我想要的是TextView显示SeekBar中的每个进度变化.
简而言之:我正在寻找一种可能获得进步监听器的可能性.
我发现在我的应用程序中,用户可以在用户使用应用程序时打开的各种活动中完全"嵌套".
例如:
现在,当用户按下时,它必须经过两次"对象子细节"(相同的对象,当它被编辑时返回到详细页面),"父对象细节"也会发生同样的事情.
有没有办法重用活动,如果它们已经在堆栈中打开,并将它们重新排序到前面?我看到的唯一方法是使用该launcher属性进行活动.我相信我看到的singleTask和singleTop.
如果我应该使用这两个属性,singleTask并且singleTop我应该如何使用它们?当我试图将它们包含在应用程序中时,它没有任何区别.使用时启动意图时是否还需要设置标志startActivity?
我想在将其添加到xml文件的主窗口后重置textView高度.
在RelativeLayout中,
<TextView
android:id="@+id/text_l"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10sp"
android:layout_marginTop="145dp"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" >
</TextView>
Run Code Online (Sandbox Code Playgroud)
我只想将它从50改为70:
我试过了:
TextView text = (TextView)findViewById(R.id.text_l);
text.setHeight(70);
Run Code Online (Sandbox Code Playgroud)
但没有改变.
我的ListView有一个简单的选择器
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/yellow_arc" android:state_activated="true"/>
<item android:drawable="@drawable/yellow_nonarc" android:state_activated="false"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
当视图的状态从激活变为未激活时,我希望为这些绘图之间的过渡设置动画,反之亦然.
如果您在API演示中运行示例,则会在视图的激活状态发生更改时看到明显的淡入/淡出动画.
所以我想要的是一个自定义动画,同时改变视图的状态.我认为它应该通过xml完成,但我找不到方法.
提前致谢.
编辑:
我想我找到了一些有用的东西activated_background.xml,\Android\android-sdk\platforms\android-API_VERSION\data\res\drawable其中包括
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:state_activated="true" android:drawable="@android:drawable/list_selector_background_selected" />
<item android:drawable="@color/transparent" />
</selector>
Run Code Online (Sandbox Code Playgroud)
因此API演示中的示例通过声明一个来实现这个淡出动画exitFadeDuration.然而,这并不是我想要的.我想为状态drawables之间的过渡声明自定义动画,因为淡入/淡出动画对我的drawable来说看起来不太好.
android ×10
android-xml ×1
animation ×1
diacritics ×1
filepath ×1
java ×1
junit ×1
pdf ×1
seekbar ×1
sqlite ×1
string ×1
textview ×1
transition ×1
uri ×1