我的应用程序中有一个SearchView小部件,我想问一些关于使它自定义的问题.首先,您只能通过点击搜索图标开始搜索,有没有办法让整个SearchView可点击?此外,还有一种方法可以在单击时使SearchView显示为这样吗?
一只忙碌的猫http://i41.tinypic.com/rr2ow4.png ![] [1]
它现在处于这种状态:
一只忙碌的猫http://i41.tinypic.com/11jlu2p.png ![] [1]
这是我的代码:
citySearch = (SearchView) findViewById(R.id.city_search_bar);
citySearch.setBackgroundResource(R.drawable.search_background);
citySearch.setOnSearchClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
citySearch.setIconifiedByDefault(true);
//citySearch.setIconified(true);
}
});
citySearch.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String text) {
((Filterable) cityListView.getAdapter()).getFilter().filter(text);
return false;
}
@Override
public boolean onQueryTextSubmit(String text) {
return false;
}
});
try
{
Field searchField = SearchView.class.getDeclaredField("mSearchButton");
searchField.setAccessible(true);
ImageView searchBtn = (ImageView)searchField.get(citySearch);
searchBtn.setImageResource(R.drawable.search_icon);
searchBtn.setScaleType(ScaleType.FIT_CENTER);
searchPlate.setBackgroundResource(R.drawable.search_background);
}
catch (NoSuchFieldException e)
{
Log.e("SEARCHSTYLEERROR",e.getMessage(),e);
}
catch (IllegalAccessException e)
{
Log.e("SEARCHSTYLEERROR",e.getMessage(),e);
}
Run Code Online (Sandbox Code Playgroud) 我在 android 中有一个应用程序,在某些情况下我想将一个 Activity 带到前台。我为此使用NotificationManager。这是我的代码。问题是,活动第一次成功地被带到前面,但后来却没有。此外,此代码是从服务运行的。
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(contentIntent)
.setContentTitle("Bring me front!")
.setContentText("Bring me!!! BRING!!!")
.setFullScreenIntent(contentIntent, true);
NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(0, mBuilder.build());
Run Code Online (Sandbox Code Playgroud) notifications android android-notifications android-activity
我想使用MPMoviePlayerController在我的iPad应用中播放视频.我的问题是,该播放器只显示"正在加载"而不播放视频.这是我使用的代码:
- (void)playMovieFile:(NSString *)fileName
{
NSString *filePath=[[NSBundle mainBundle] pathForResource:fileName ofType:@"mov"];
NSURL *fileUrl=[NSURL fileURLWithPath:filePath];
self.moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:fileUrl];
[self.moviePlayer.view setFrame:self.view.frame];
[self.view addSubview:self.moviePlayer.view];
[self.moviePlayer prepareToPlay];
[self.moviePlayer play];
}
Run Code Online (Sandbox Code Playgroud)
我也尝试使用MPMoviePlayerViewController,但神志清醒success.Also,什么电影类型做的MPMoviePlayerController播放?可以因为电影的大小吗?它是263 MB.
我的问题如下:我有一个java代码,用一个.java文件编写 - Chain_of_Responsibility,代码在我的问题的最后.我用Linux编译它
javac Chain_of_Responsibility.java
Run Code Online (Sandbox Code Playgroud)
并将所有我的.class文件放在同一目录中.然后我尝试运行我的程序
java Chain_of_Responsibility
Run Code Online (Sandbox Code Playgroud)
并获得"线程中的异常"主"java.lang.NoClassDefFoundError:Chain_of_Responsibility".我试着让我的main函数静态,在不同的.java文件中编写所有类,但没有成功.所以我不知道该怎么做.你能帮助我吗?
package COR;
public class Chain_of_Responsibility
{
public void main(String[] args)
{
//Create the Chain of Responsibility
Handler chain = build_chain();
//Trying to handle the request (valid are cheese, meet or banana)
chain.handle_request(args[1]);
}
private Handler build_chain()
{
//Creating the chain
Handler monkey = new Monkey();
Handler wolve = new Wolve();
Handler mouse = new Mouse();
//First nide is Monkey, then Wolve and then Mouse
monkey.set_next_handler(wolve);
wolve.set_next_handler(mouse);
//Returning the first node in …Run Code Online (Sandbox Code Playgroud)