是否可以将Google地图v3限制在某个区域?我想允许只显示某个区域(例如国家/地区)并禁止用户滑动到其他位置.此外,我想限制缩放级别 - 例如仅在级别6和9之间.我想使用所有基本地图类型.
有没有办法实现这个目标?
我通过使用StyledMap限制缩放级别取得了部分成功,但我仅限制了ROADMAP,我无法通过这种方式限制其他基本类型的缩放.
谢谢你的帮助
我想知道是否ColorFilter可以在XML的XML中设置,View或者是否唯一的方法是setColorFilter()在Java中使用.
我应用自定义View的ActionBar,像这样的
// Inflate the "Done/Discard" custom ActionBar view.
LayoutInflater inflater = (LayoutInflater) DetailsHost.mActionBar
.getThemedContext().getSystemService(DetailsHost.LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(
R.layout.actionbar_custom_view_done_discard, null);
// Show the custom ActionBar view and hide the normal Home icon and title.
DetailsHost.mActionBar.setDisplayOptions(
ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME
| ActionBar.DISPLAY_SHOW_TITLE);
DetailsHost.mActionBar.setCustomView(customActionBarView,
new ActionBar.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
Run Code Online (Sandbox Code Playgroud)
(基于Roman Nuriks代码).
如何恢复初始布局?注意:我使用ActionBarSherlock
我想调整我ImageButton使用鼠标的图形布局或使用代码的
android:layout_width,android:layout_height.但是每当我这样做时,它ImageButton都没有调整大小,实际上它并不小,但它在边缘被切割.
提前致谢
我在这个网站上阅读了很多关于如何在Android中接收UDP数据包的帖子.但是,这对我来说都不起作用!
一些基础知识:
我正在测试运行在3G上的HTC Incredible(Android 2.2)(不是wifi或其他任何东西).这里不涉及模拟器.
我的代码很简单:
//Server code to initialize the UDP socket (snippet)
public void init() {
datagram_server_socket = new DatagramSocket(port,local_addr);
datagram_server_socket.setSoTimeout(1000);
}
Run Code Online (Sandbox Code Playgroud)
// ANDROID APP上的代码片段,用于将数据包发送到服务器
public void connect() {
Random r = new Random(System.currentTimeMillis());
int udp_port = 0;
while(true){
try {
udp_port = r.nextInt(1000)+8000;
udp_port = 8000;
comm_skt = new DatagramSocket(udp_port);
Log.i("ServerWrapper", "UDP Listening on port: " + udp_port);
break;
} catch(SocketException e) {
Log.e("ServerWrapper", "Could not bind to port " + udp_port);
} …Run Code Online (Sandbox Code Playgroud) 我的小部件支持小部件调整大小。
但是,当小部件大小更改时,文本大小保持不变。我应该怎么处理?
我正在寻找诸如文本大小百分比之类的东西,这取决于小部件的大小。
Android 4.1 ActionBar提供了一个有用的导航模式作为列表或选项卡.我正在使用a SpinnerAdapter从三个片段中进行选择以在视图中显示android.R.id.content.然后,onNavigationItemSelected()侦听器将每个片段膨胀到视图,并使用它将其添加到后台堆栈FragmentTransaction.addToBackStack(null).
这一切都像宣传的那样工作,但我不知道如何更新ActionBar以反映当前的后台.使用ActionBar.setSelectedNavigationItem(position)作品,但也触发一个新的OnNavigationListener(),也创造另一个FragmentTransaction(不是我想要的效果).代码如下所示,以便澄清.任何解决方案的帮助表示赞赏.
public class CalcActivity extends Activity {
private String[] mTag = {"calc", "timer", "usage"};
private ActionBar actionBar;
/** An array of strings to populate dropdown list */
String[] actions = new String[] {
"Calculator",
"Timer",
"Usage"
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
// may not …Run Code Online (Sandbox Code Playgroud) 我正在开发的应用程序有一个扩展的活动SherlockFragmentActivity.我想使用首选项api,以便轻松地为活动添加首选项.由于我想支持api 8级及以上,我必须从课堂上扩展活动SherlockPreferenceActivity.
问题是活动需要显示一个对话框.对话框扩展SherlockDialogFragment.show()对话框的方法需要两个参数:FragmentManager对象和String标记.
为了获得FragmentManager对象,我习惯于调用getSupportFragmentManager()活动的方法.缺少这种方法SherlockPreferenceActivity.我尝试使用,getFragmentManager()但Eclipse说
DialogFragment类型中的方法show(FragmentManager,String)不适用于参数(FragmentManager,String)
如何显示对话框片段SherlockPreferenceActivity?
我希望在a的顶部有一个分隔符ListView(放在其中RelativeLayout),但是当我尝试使用它时,我只得到底部分隔符:
<ListView
android:id="@+id/last_contacts_picked_list"
android:headerDividersEnabled="true"
android:footerDividersEnabled="true"
android:paddingTop="50dp"
android:dividerHeight="5dp"
android:layout_marginTop="50dp"
android:divider="@android:drawable/divider_horizontal_textfield"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="..."
android:layout_alignLeft="..."
android:layout_alignRight="..."
android:layout_below="..."
/>
Run Code Online (Sandbox Code Playgroud)
我有这样的事情:
http://i051.radikal.ru/1211/4f/a408db5e717f.png
为什么它也没有标题分隔符呢?
我试图在我的所有应用程序中放置一种样式,所以我创建了一个包含我的样式的主题:
<resources>
<style name="MyTheme" parent="android:Theme.Holo.Light">
<item name="android:textAppearance">@style/subtitle</item>
</style>
<style name="subtitle parent="@android:style/TextAppearance">
<item name="android:textColor">@color/purple</item>
<item name="android:textSize">40sp</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
但textAppearance不起作用它保持不变,但是当我textColor在我的主题中放入类似的东西时,它起作用了
我在ubuntu专用服务器上编辑/扩展我的防火墙bash脚本.
下面的代码只是一个摘录.下面的目的是重新路由/打开一些IP我的(http,ftp,telnet和ssh)端口为/ 3箱.
问题是我想在变量中使用变量.因此--dport ${i}_${j}_port_ext被fi正确替换--dport box0_http_port_ext但不被视为变量(当然).实际上,我想要的应该是--dport $box0_http_port_ext($开头)
我试过几件事情科幻--dport ${${i}_${j}_port_ext}或--dport $(${i}_${j}_port_ext)但这并不是很好.
box0_http_port_ext="8080"
box0_ftp_port_ext="21"
box0_telnet_port_ext="23"
box0_ssh_port_ext="22"
#
allow_box0_http_port_ip="1.2.3.4 99.98.97.96 55.56.57.58"
allow_box0_ftp_port_ip="1.2.3.4 55.56.57.58"
allow_box0_telnet_port_ip="55.56.57.58"
allow_box0_ssh_port_ip="1.2.3.4"
#
for i in box0 box1 box2
do
for j in http ftp telnet ssh
do
for ips in $allow_${i}_${j}_port_ip
do
$IPTABLES -t nat -A PREROUTING -p tcp -i $LAN_IFACE -s $ips --dport ${i}_${j}_port_ext -j DNAT --to-destination ${i}_ip:${i}_${j}_port_int
done
done
done
Run Code Online (Sandbox Code Playgroud)
请不要查看代码,因为它是摘录,因此不完整.
现在的问题是:如何编写代码--dport $box0_http_port_ext通过利用 …
嗨,这些问题似乎非常基本,但我没有找到任何答案.
当我们setContentView(R.layout.somelayout)然后我们的布局XML文件被LayoutInflater服务inflatted .但我想知道它究竟发生在哪里.我没有在活动源代码中找到任何膨胀xml文件的代码.
还有哪些是为R中的视图生成的ID?
提前致谢.
android ×10
java ×2
resize ×2
xml ×2
bash ×1
divider ×1
google-maps ×1
header ×1
imagebutton ×1
javascript ×1
listview ×1
shell ×1
ubuntu ×1
udp ×1
variables ×1