小编MrG*_*age的帖子

为什么我的android活动总是开始滚动到底部?

每当我开始这项活动时,它总是从最低点开始 - 一直向下滚动到底部.我没有在活动OnCreate(或其他任何地方)做任何奇怪的事情,我希望改变滚动位置.我已经尝试将焦点设置到最顶层的可聚焦控件和scrollto方法,但它们都没有工作.此外,我的其他活动都没有这个问题.这是布局:

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroll"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/edit_refresh_update_header"
            android:textSize="18sp"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="\n"
            android:textSize="4sp"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Variable:"
            android:textSize="18sp"/>

        <Spinner
            android:id="@+id/edit_refresh_variables_spinner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="\n"
            android:textSize="4sp"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Network:"
            android:textSize="18sp"/>

        <RadioGroup
            android:id="@+id/widget1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical">

            <RadioButton
                android:text="Web"
                android:id="@+id/edit_refresh_update_rb_web"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="NetRadioButtonSelected"
                android:checked="true"/>

            <RadioButton
                android:text="Socket Server"
                android:id="@+id/edit_refresh_update_rb_socket_server"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="NetRadioButtonSelected"/>
        </RadioGroup>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="\n"
            android:textSize="4sp"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Socket server request type:"
            android:textSize="18sp"/>

        <Spinner
            android:id="@+id/edit_refresh_socket_server_req_types_spinner"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

        <TextView …
Run Code Online (Sandbox Code Playgroud)

layout android

87
推荐指数
2
解决办法
4万
查看次数

eclipse jsp函数fn:escapeXml是未定义的

我正在开始我的第一个谷歌应用引擎jsp项目.我从这里开始关注留言簿的教程:https://developers.google.com/appengine/docs/java/gettingstarted/introduction.我对数据存储步骤(https://developers.google.com/appengine/docs/java/gettingstarted/usingdatastore),并在该网页上的代码都直接粘贴到我的项目.代码编译和工作,但我得到fn:escapeXml调用下的红色波浪形下划线.我看到这些是来自taglib的函数,如下所述:http://www.tutorialspoint.com/jsp/jsp_standard_tag_library.htm.那么,我如何让eclipse知道发生了什么,而不是认为这是一个错误?

eclipse jsp taglib

11
推荐指数
2
解决办法
1万
查看次数

Android TextView文本不会居中

我正在尝试进行PIN输入活动,但是一件小事对我来说并不适合.我无法将文本放在屏幕顶部的TextView中心:

Pin截图

它的工作方式是当用户输入PIN时,我会在每个TextView中放置一个星形以获得可见的反馈.问题是,我希望明星能够居中.我试过layout_gravity ="center",但它并没有什么区别.这是我目前的布局:

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
     <TextView 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:layout_height="wrap_content" 
     android:id="@+id/textView1" 
     android:text="PIN Required" 
     android:layout_width="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginBottom="12sp"
     ></TextView>
     <LinearLayout 
     android:layout_width="match_parent" 
     android:id="@+id/linearLayout1" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="12sp" 
     android:layout_gravity="center_horizontal"
     >
         <TextView 
       android:id="@+id/text1" 
       android:layout_height="32sp" 
       android:layout_width="48sp" 
       android:layout_weight="1" 
       android:layout_marginRight="2sp" 
       android:layout_marginLeft="48sp" 
       android:background="#FFFFFF" 
       android:text="X" 
       android:layout_gravity="center"
       ></TextView>
         <TextView 
       android:id="@+id/text2" 
       android:layout_height="32sp" 
       android:layout_width="48sp" 
       android:layout_weight="1" 
       android:layout_marginRight="2sp" 
       android:layout_marginLeft="2sp" 
       android:background="#FFFFFF"
       ></TextView>
         <TextView 
       android:id="@+id/text3" 
       android:layout_height="32sp" 
       android:layout_width="48sp" 
       android:layout_weight="1" 
       android:layout_marginRight="2sp" 
       android:layout_marginLeft="2sp" 
       android:background="#FFFFFF"
       ></TextView>
         <TextView 
       android:id="@+id/text4" 
       android:layout_height="32sp" 
       android:layout_width="48sp" 
       android:layout_weight="1" 
       android:layout_marginRight="48sp" 
       android:layout_marginLeft="2sp" 
       android:background="#FFFFFF"
       ></TextView>
     </LinearLayout>
     <LinearLayout 
     android:layout_width="match_parent" 
     android:id="@+id/linearLayout2" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="12sp"
     >
         <Button 
       android:text="1" 
       android:textColor="#FFFFFF" 
       android:id="@+id/button1" 
       android:layout_height="32sp" 
       android:layout_width="64sp" 
       android:layout_weight="1" …
Run Code Online (Sandbox Code Playgroud)

layout android textview

8
推荐指数
2
解决办法
3万
查看次数

Android appwidget点击不起作用

天哪,这里肯定有一千个不同的关于 android appwidget 的教程,还有更多的问题,但我就是不明白为什么我的不工作。叹息 反问:为什么这里的代码不能与几乎所有其他带有 setOnClickListener 的对象相同(new new Button.OnClickListener() { // do stuff }... 无论如何,我的小部件显示在屏幕上并且标签是正确的,但是当我点击小部件时,什么也没发生。我在所有我认为会发生某些事情的地方放置了断点,但没有执行任何操作。

问题1:点击widget后执行什么代码?

我的小部件在被点击时并没有真正更新。相反,它只是在我的程序的其余部分执行一些代码。它只是生成一些网络 http 和/或套接字服务器命令。此外,我的小部件在放置在桌面上之前配置了一个活动。

这是清单:

 <receiver android:name="PhcaAppWidgetProvider" >
     <intent-filter>
         <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
         <action android:name="com.skipmorrow.phca.PhcaAppWidgetProvider.WIDGET_CLICKED" />
     </intent-filter>
     <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/phca_widget_info" />
 </receiver>
Run Code Online (Sandbox Code Playgroud)

这是小部件配置器活动

    private Activity act;
    private static ListView listView;
    private static ArrayAdapter<String> adapter;
    private ArrayList<String> actionList;
    private final String widgetPageName = "_widget";
    int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
     private static final String PREFS_NAME = "PHCA";
     private static final String PREF_PREFIX_KEY = "prefix_";

    @Override
    public void onCreate(Bundle …
Run Code Online (Sandbox Code Playgroud)

android widget click

6
推荐指数
1
解决办法
5206
查看次数

Android imageview从缩放图像中获取像素颜色

我的家庭自动化应用程序具有以下功能:人们可以使用平面图和仪表板将图像上传到手机,以便控制家庭自动化软件.我让他们上传了两张图片:一张带有他们想要显示的图片的可见图片,另一张带有纯色的颜色图,对应于他们想要从可见图像中定位区域的对象.两个图像必须具有相同的大小,以像素为单位.当他们点击屏幕时,我希望能够从colormap覆盖图中获取颜色,然后我继续执行与该颜色相关联的操作.问题是,图像的缩放让我感到困惑.他们使用的图像可能比设备屏幕大,所以我缩放它们以便它们适合显示器.我现在不需要捏缩放功能,但我可能会在以后实现它.现在,我只想让图像以最大尺寸显示,以便它适合屏幕.所以,我的问题是,我怎么能修改这个代码,以便我可以从缩放的图像中获得正确的接触点颜色.图像缩放本身似乎工作正常.它被缩放并正确显示.我只是无法获得正确的接触点.

 final Bitmap bm = decodeSampledBitmapFromFile(visible_image, size, size);
 if (bm!=null) {
    imageview.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    imageview.setImageBitmap(bm);
 }

 final Bitmap bm2 = decodeSampledBitmapFromFile(image_overlay, size, size);
 if (bm2!=null) {
    overlayimageview.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    overlayimageview.setImageBitmap(bm2);

    imageview.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent mev) {
            DecodeActionDownEvent(v, mev, bm2);
            return false;
        }

    });
 }

 private void DecodeActionDownEvent(View v, MotionEvent ev, Bitmap bm2)
 {
    xCoord = Integer.valueOf((int)ev.getRawX());
    yCoord = Integer.valueOf((int)ev.getRawY());
    try {
        // Here's where the trouble is.
        // returns the value of the unscaled pixel at the scaled touch …
Run Code Online (Sandbox Code Playgroud)

android imageview

6
推荐指数
1
解决办法
6304
查看次数

android imageview长按和常规按

我有一个imageview,我需要长按(上下文菜单)和常规印刷机工作.我可以让一个或另一个工作,但不是两个.我错过了什么?以下代码仅适用于常规印刷机.一触摸屏幕,它就开始执行onTouch代码.

 ImageView image = (ImageView)findViewById(R.id.visible_image);
 image.setLongClickable(true);
 image.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent ev) {
        switch (ev.getAction()) {
         case MotionEvent.ACTION_DOWN:
            // disable the screen taps for 500ms
            DecodeActionDownEvent(v, ev, bm2);
         case MotionEvent.ACTION_MOVE:
         case MotionEvent.ACTION_UP:
     }
        return true;
    }
 });
 registerForContextMenu(image);
Run Code Online (Sandbox Code Playgroud)

...

 @Override
 public void onCreateContextMenu(ContextMenu menu, View v,
     ContextMenuInfo menuInfo) {
    menu.setHeaderTitle("Edit");
    ArrayList<String> menuItems = new ArrayList<String>();
    menuItems.add("Edit page settings");
    menuItems.add("Edit page objects");
    menuItems.add("Edit this object");
    for (int i = 0; i<menuItems.size(); i++) {
        menu.add(Menu.NONE, i, i, menuItems.get(i));
    } …
Run Code Online (Sandbox Code Playgroud)

android contextmenu imageview

5
推荐指数
1
解决办法
2万
查看次数

Android appWidget多个实例

这个问题几乎与Android相同-多个appWidgets播放不同的声音,但是我的代码无法正常工作。我在小部件ID中添加了一个意向附加内容,并带有日志语句来证明这一点,但是当我在多个小部件中单击一个小部件时,只有它的最后一个appWidgetId才有意义。添加第二个小部件后,第一个小部件的意图似乎正在改变。如果另一篇文章中的代码可以工作,那么我必须忽略一些东西,因为我相信我的设置方法几乎相同。

 public class PhcaAppWidgetProvider extends AppWidgetProvider {
     private static final String ACTION_CLICK = "com.skipmorrow.phca.PhcaAppWidgetProvider.WIDGET_CLICKED";
     private final String widgetPageName = "_widget";
     private static final String PREFS_NAME = "PHCA";
     private static final String PREF_PREFIX_KEY = "prefix_";
     private static String MY_DEBUG = "PhcaAppWidget";

     @Override
     public void onUpdate(Context context, AppWidgetManager appWidgetManager,
             int[] appWidgetIds) {
        Log.d(MY_DEBUG, "Provider.onUpdate");
     }

     @Override
     public void onReceive(Context context, Intent intent) {
        String intentAction = intent.getAction();
        Log.d(MY_DEBUG, "Provider.onReceive(); action = " + intentAction);
        Bundle extras = intent.getExtras();

        // make …
Run Code Online (Sandbox Code Playgroud)

android android-appwidget

4
推荐指数
1
解决办法
4133
查看次数

Android启动器图标不起作用

我有一个我正在开发的Android应用程序.我创建了图标(.png)并将它们放在/res/drawable-hdpi(和ldpi&mdpi)文件夹中.在我的清单中,我有

<application android:icon="@+drawable/icon" android:label="@string/app_name">
Run Code Online (Sandbox Code Playgroud)

我的图标都名为icon.png.

我编译了源代码,当我在模拟器上运行它时,图标显示在桌面启动器中.但是当我将apk复制到我的实际手机时,桌面启动器会显示默认包图标而不是我的自定义图标.虽然,当我实际安装应用程序时,有趣的是,包管理器确实显示了图标.但是一旦安装,图标就不会显示.

如何使我的应用程序图标显示为启动器图标?

跳跃

android android-manifest

3
推荐指数
1
解决办法
9499
查看次数

Java位移...请解释

我正在审查闹钟项目中的一些代码.该代码使用整数来存储重复的警报信息.也就是说,发生的警报就像每个MWF一样.我理解整数只是一系列字节,每个字节都是一系列位,因此您可以使用该位信息创建一个整数,该整数对于一周中的每个日期模式都是唯一的.我不明白的是这些功能的逻辑:

// is a given day "set"?
private boolean isSet(int day) {
  return (mDays & (1 << day)) > 0;
}

// set a given day to on or off
public void set(int day, boolean set) {
    if (set) {
        mDays |= (1 << day);
    } else {
        mDays &= ~(1 << day);
    }
}
Run Code Online (Sandbox Code Playgroud)

有人可以解释这两个功能的作用以及它们的工作原理吗?

java

2
推荐指数
1
解决办法
104
查看次数

处理C#名称空间

我正在开发一个需要能够下载YouTube视频的项目.我在github上找到了这个项目:

https://github.com/flagbug/YoutubeExtractor

我的项目已经有了命名空间.如何将YoutubeExtractor导入我的项目?我需要在导入它之前(或之后)更改它的命名空间吗?或者由我决定,在这种情况下,更改命名空间与不更改命名空间有什么优缺点?我正在使用VS Express 2012,如果这很重要的话.

.net c#

0
推荐指数
1
解决办法
140
查看次数