有谁知道如何将换行符放在节点的标签上?\n不起作用 - 而是出现一些新节点.
如何将位置更新直接发送到Intent Service?以下方法不起作用.调用OnConnected函数,但从未在服务中接收到intent:
...
private PendingIntent getLocationPendingIntent(boolean shouldCreate) {
Intent broadcast = new Intent(m_context,LocationUpdateService.class);
int flags = shouldCreate ? 0 : PendingIntent.FLAG_NO_CREATE;
return PendingIntent.getService(m_context, 0, broadcast, flags);
}
@Override
public void onConnected(Bundle arg0) {
PendingIntent locationPendingIntent = getLocationPendingIntent(true);
LocationRequest locationRequest = new LocationRequest();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(LOCATION_UPDATE_INTERVAL);
locationRequest.setFastestInterval(LOCATION_FASTEST_UPDATE_INTERVAL);
LocationServices.FusedLocationApi.requestLocationUpdates(m_googleApiClient, locationRequest,locationPendingIntent);
}
...
Run Code Online (Sandbox Code Playgroud)
意向服务:
import android.app.IntentService;
import android.content.Intent;
import android.util.Log;
public class LocationUpdateService extends IntentService {
public LocationUpdateService() {
super(LocationUpdateService.class.getName());
}
@Override
public int onStartCommand(Intent intent, int flags, int startID) {
super.onStartCommand(intent, flags, startID); …Run Code Online (Sandbox Code Playgroud) 每次(除了第一次)我在JEditorPane滚动条中设置文本跳转到JEditorPane的底部.有什么方法可以避免这种情况吗?我试过的一种方法是在setText()之后使用setCaretPosition(0).它有效,但它不是我需要的.滚动条跳下然后跳起来.有没有办法避免在settext()中滚动条的任何移动?
我的代码:
package test;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
public class Test extends JApplet implements HyperlinkListener {
JEditorPane dataDisplayer = new JEditorPane();
public void init() {
ataDisplayer.setEditable(false);
dataDisplayer.add(new JButton());
dataDisplayer.setContentType("text/html");
JScrollPane jsp = new JScrollPane(dataDisplayer);
dataDisplayer.setText("<a href=''>Change Text</a><br><br><br><br><br><br><br><br><br><br>bla");
this.dataDisplayer.addHyperlinkListener(this);
setContentPane(jsp);
}
@Override
public void hyperlinkUpdate(HyperlinkEvent arg0) {
dataDisplayer.setText("<a href=''>Change Text</a><br><br><br><br><br><br><br><br><br><br>bla bla");
}
}
Run Code Online (Sandbox Code Playgroud)