我有一个列表活动,其项目由图像+文本组成.我需要允许用户更改视图并使用gridview而不是它(其元素仍然由相同的图像+文本组成).
用户可以通过图标菜单完成:
public boolean onOptionsItemSelected(MenuItem item)
{
if(item.getItemId()== R.id.change_view)
{
// ?
}
}
Run Code Online (Sandbox Code Playgroud)
我试图设置新的适配器(见下文),但它不起作用..我必须创建一个新的活动来做到这一点?
if(item.getItemId()== R.id.change_view)
{
setContentView(R.layout.grid_view);
gridViewAdapter = new GridViewAdapter(this,R.layout.bookmark_list_item,MyApp.getItems().findAll());
list.setAdapter(gridViewAdapter);
list.setVisibility(View.VISIBLE);
}
Run Code Online (Sandbox Code Playgroud) 我正在开发下载图像的应用程序.当用户单击下载图像链接时,我已成功触发我的应用程序.如何过滤特定的URL?
这里我的清单代码:
<activity android:theme="@style/Transparent" android:name=".DownloadImage"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="image/*" android:host="*"
android:scheme="http" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
当用户点击浏览器中的任何链接但不触发特定网址时,我的应用程序将启动并下载图像,例如"http://www.ABC.com"或特定项目"http://www.ABC.com/图像/ background.jpg"
关于在我的应用程序中存储下载内容的位置的许多单独但相关的问题.
我有一个从中央服务器下载内容的应用程序.此内容有时是高级内容,或者至少是发布者不希望其自由分发的内容.我知道"外部"存储很容易访问,而"内部"存储是受保护的,除非电话是根的.
如果应用程序安装在SDCARD上(因为我的配置是),那么SDCARD上的"内部"存储也是物理上的吗?因此,如果我的SDCARD安装的应用程序下载了100MB的内容到内部存储,那么它实际上是在SDCARD上结束了,还是最终在设备的物理板载存储中?
如果应用程序安装在SDCARD上,并且带有下载内容的"内部"存储器位于SDCARD上,那么它是以开放格式物理存储还是加密?我似乎记得读过存储在SDCARD上的应用程序是加密的.这也适用于"内部"存储吗?
(删除有关将文件存储在单个目录中的问题,如Context.getDir()意味着可以在内部存储中创建和维护目录系统)
有更好的方法吗?
我有一个适配器,我使用一个 ad.getFilter().filter(s);过滤器listView.
如果我在EditText中写一个单词,它的效果很好.
如果在单词后写一个空格字符,它不起作用(结果没有行).
我想用名称和surmane做一个过滤器.我想插入"Mario Rossi"edittext并得到一个结果..我希望我解释.
非常感谢.
private TextWatcher filterTextWatcher = new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
ad.getFilter().filter(s);
}
};
Run Code Online (Sandbox Code Playgroud) 我想使用DrawingCache捕获ImageView的内容.我写了下面的代码.
iv1 = (ImageView)findViewById(R.id.iv1);
iv2 = (ImageView)findViewById(R.id.iv2);
iv1.setDrawingCacheEnabled(true);
Bitmap myScreenshot = iv1.getDrawingCache();
iv2.setImageBitmap(myScreenshot);
Run Code Online (Sandbox Code Playgroud)
但我在屏幕上只得到一张图片.后来我才知道myScreenshot是空的
我看到很多关于同样问题的帖子,但没有适当的解决方案.
我认为我们必须在清单中添加任何权限?实现这一目标需要root权限?请帮我解决这个问题.
我有一个Hello现在称为文本的文本我需要在文本大小增加的文本中应用字体后立即对此说12或18应用fontsize.
所以现在我需要使用paint获取文本高度,包括字体大小.
我尝试过以下涂料:
String finalVal ="Hello";
Paint paint = new Paint();
paint.setTextSize(18);
paint.setTypeface(Typeface.SANS_SERIF);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL);
Rect result = new Rect();
// Measure the text rectangle to get the height
paint.getTextBounds(finalVal, 0, finalVal.length(), result);
Run Code Online (Sandbox Code Playgroud)
但它不起作用,请帮忙
编辑
我试图根据textheight动态设置webview的高度我得到单行的文本高度,"Hello"但如果文本中有两行"My name is abc and my dads name is xyz and my moms name is 123" now its not getting the proper text height".
我身上有背景图片.我想要实现的是:
1) - 计算访客屏幕分辨率.
2) - 基于该分辨率,我想调整背景图像的大小.
我知道屏幕分辨率为
Display display = getWindowManager().getDefaultDisplay();
width_screen = display.getWidth();
height_screen = display.getHeight();
Run Code Online (Sandbox Code Playgroud)
但我不知道如何根据用户的屏幕分辨率调整图像大小.
有人可以帮忙吗?谢谢..
我正在开发一个Android应用程序,它应该每天发出五次警报:
- 每天的时间不是恒定的
- 警报发出后我将安排下一次警报.
我的问题是:警报通知工作1天然后它停止,并且当设备重新启动两次通知不起作用,我现在不,如果还有另一种方法,任何帮助将非常感谢!
代码:我有这个功能来调用广播接收器
public static void Start_Notifying(Context context){
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.add(Calendar.HOUR_OF_DAY,hour);
cal.add(Calendar.MINUTE, min);
Intent intent = new Intent(context, OnetimeAlarmReceiver.class);
intent.setAction("START_NOTIFYING");
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notify.REQUEST_CODE, intent,0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis() , pendingIntent);
SaveAlarmManager(alarmManager, pendingIntent);
}
Run Code Online (Sandbox Code Playgroud)
oneTimeAlarmReciever的代码
public void onReceive(Context context, Intent intent) {
main_menu.con = context;
Notification notifyDetails;
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
notifyDetails = new Notification(R.drawable.icon,s1,System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(context, REQUEST_CODE, new Intent(context, prayertimes.class), 0);
notifyDetails.setLatestEventInfo(context,s2+ notify.prayName , s3, pendingIntent); …Run Code Online (Sandbox Code Playgroud) android broadcastreceiver android-manifest alarmmanager android-alarms
我在对话框中制作了一个edittext但我无法改变高度.
AlertDialog.Builder editalert = new AlertDialog.Builder(this);
editalert.setTitle("messagetitle");
editalert.setMessage("here is the message");
final EditText input = new EditText(this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
input.setLayoutParams(lp);
editalert.setView(input);
editalert.setPositiveButton("Send via email", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
editalert.show();
Run Code Online (Sandbox Code Playgroud) 我想过滤我listView使用一个EditText盒子并使用适配器getFilter()功能.它工作得很好,直到我在文本框中放置一个空格字符.
编辑:这是一个SimpleAdapter而不是ArrayAdapter
如果我的列表中包含以下单词:{"Apple","Banana","Red Apple"}如果我输入"apple",它将返回包含苹果字样的所有项目(Apple和Red Apple).如果我输入"apple",它将不会返回任何内容.
有任何想法吗?这是代码:
searchBox = (EditText) findViewById(R.id.searchBox);
searchBox.addTextChangedListener(filterTextWatcher);
Run Code Online (Sandbox Code Playgroud)
和
private TextWatcher filterTextWatcher = new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
myAdapter.getFilter().filter(s.toString());
}
};
Run Code Online (Sandbox Code Playgroud) android ×10
listview ×3
adapter ×2
filter ×2
alarmmanager ×1
gridview ×1
intentfilter ×1
java ×1
layoutparams ×1
paint ×1
performance ×1
screenshot ×1
storage ×1