我只想在android中的webview中显示带有一些文本和其他内容的本地图像.
即我有webview st
WebView mWebView = (WebView) otherappView.findViewById(R.id.webView1);
String summary =readRawTextFile(context, R.raw.abc);
mWebView.loadData(summary, "text/html", null);
Run Code Online (Sandbox Code Playgroud)
并在abc.html文件中我应该为图像的src标签写什么(???? part)
<img width="48" height="48" src="??????" class="attachment-48x48 wp-post-image" alt="" title="analogklasik48" />
Run Code Online (Sandbox Code Playgroud)
ps项目是一个图书馆项目,所以我不想使用资产文件夹
ps文件:///android_res/drawable/image.png不起作用
我已经创建了http://code.google.com/p/libgdx/wiki/ProjectSetup中描述的三个项目,并且运行桌面版本有效,但是当我在模拟器上运行android版本时,我收到以下错误.主项目是在android项目的构建路径中,eclipse构建了所有内容而没有错误.我错过了什么?
10-31 07:06:47.023: E/dalvikvm(769): Could not find class 'com.mygame.MyGame',
referenced from method com.mygame.MyGameAndroid.onCreate
Run Code Online (Sandbox Code Playgroud) 我正在开发Android 2.1上的任务管理器.我想为datepicker中的日期设置任务设置警报和时间选择器的时间帮助我使用代码..
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText next = (EditText) findViewById(R.id.editText1);
final Button sub = (Button) findViewById(R.id.button1);
final Button res = (Button) findViewById(R.id.button2);
final DatePicker dp = (DatePicker) findViewById(R.id.datePicker1);
final TimePicker tp = (TimePicker) findViewById(R.id.timePicker1);
sub.setOnClickListener(new View.OnClickListener() {
public void onClick(final View view) {
int y=dp.getYear();
int mo=dp.getMonth();
int day=dp.getDayOfMonth();
Time t = new Time();
int h=t.getCurrentHour();
int m=t.getCurrentMinutes();
}
private AlarmManager getSystemService(String alarmService) {
// TODO Auto-generated method stub
return null;
}
});
Run Code Online (Sandbox Code Playgroud) 我想将图像插入editText,我的代码是:
CharSequence charSeq= editText.getText()+" ";
SpannableString ss2 = new SpannableString(charSeq);
Drawable d2 = holder.image.getDrawable();
d2.setBounds(0, 0, d2.getIntrinsicWidth(), d2.getIntrinsicHeight());
ImageSpan span2 = new ImageSpan(d2, ImageSpan.ALIGN_BASELINE);
ss2.setSpan(span2,charSeq.length()-1, charSeq.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
editText.setText(ss2,BufferType.SPANNABLE);
Run Code Online (Sandbox Code Playgroud)
我的代码可以运行,但我有一些不错的经验,我想修改:
1:你知道什么时候使用ss2.setSpan()方法,图像可以替换字符,我只想插入新图像,不要想图像替换字符.
2:你知道我的方法包括"editText.getText()+"";",我添加一些额外的空间,以便图像可以插入最后的CharSequence.如何不需要添加一些额外的,图像也插入最后的CharSequence.
3.当我将图像插入CharSequence的最后一个时,光标不在最后,它出现在CharSequence的前面.如何将光标放在图像后面.
4.i想在不同的CharSequence中不断插入图像,怎么办?
我的问题很多,我希望你能帮助我,非常感谢你.
我正在使用一个代码来列出我设备中的所有图像......我正试图弄清楚如何仅从特定文件夹获取图像,而不是所有图像.这是我正在使用的代码:
ArrayList<Bitmap> images = new ArrayList<Bitmap>();
String[] projection = {MediaStore.Images.Thumbnails.DATA};
Uri uri = Uri.parse("content://media/external/images/media");
cursor = managedQuery( uri, projection, null, null, null);
//cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
Log.i("MediaStore.Images.Media.EXTERNAL_CONTENT_URI", "MediaStore.Images.Media.EXTERNAL_CONTENT_URI: " + MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
if(cursor.getCount()==0){
Log.i("No Cards","No Cards");
cursor.close();
} else if(cursor.getCount()>0){
for(cursor.moveToFirst(); cursor.moveToNext(); cursor.isAfterLast()){
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
String imagePath = cursor.getString(columnIndex);
Log.i("imagePath", "imagePath: " + imagePath);
Bitmap b = BitmapFactory.decodeFile("/Stampii" + imagePath, null);
images.add(b);
}
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是从imagePath: /mnt/sdcard/Stampii/MediaCategory-251.jpgStampii文件夹中获取图像,但我无法理解如何输入该文件夹的正确路径.我已经尝试过了:
Uri uri = Uri.parse("content://media/external/images/media/mnt/sdcard/Stampii");
Run Code Online (Sandbox Code Playgroud)
有解决方案吗
我想在我的应用程序中从ymail/gmail发送电子邮件,即时通讯使用java邮件发送电子邮件我如何导入我的ymail/gmail联系人,以便我可以选择发送邮件给谁.
就像在按钮上单击它显示我的ymail/gmail联系人..我正在做这件事
final Button send = (Button) this.findViewById(R.id.send);
send.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
GMailSender sender = new GMailSender("EMAIL","PASSWORD");
sender.sendMail("This is Subject",
"This is Body",
"SENDER",
"RECIIPIENTS");
} catch (Exception e) {
Log.e("SendMail", e.getMessage(), e);
}
Run Code Online (Sandbox Code Playgroud)