好吧,我为这段代码的草率而道歉,但我仍然无法弄清楚如何在这里正确发布代码标签.所以我正在制作一个Android应用程序(Java),我有一个滚动的文本字段.如果用户向下滚动一行并在他们点击下一行时停留在最后一行,如果它很短,那么即使它可能是一行(并且不可滚动),它也会在该元素上向下滚动.我想知道是否有任何方法可以在txtLvlInfo.setText之后立即调用某些内容来将x-scroll值重置为0或其他什么以便始终将其重置为内容的顶部,无论是长还是短.感谢您对此的任何帮助,如果我需要澄清更多,请告诉我.
TextView txtLvlInfo = (TextView) findViewById(R.id.txtLevelInfo);
txtLvlInfo.setMovementMethod(new ScrollingMovementMethod());
switch (v.getId()){
case R.id.row1:
txtLvlInfo.setText("1: My text view is only two lines max and so I set it to scroll, if the user clicks row2 to load that text while having me scrolled down they have to click and pull to drag back down to the top of text view 2 row.");
break;
case R.id.row2:
txtLvlInfo.setText("I only fill line 1 of the two.");
break;
}
Run Code Online (Sandbox Code Playgroud)
_
<TextView
android:textColor="#052027"
android:text=""
android:id="@+id/txtLevelInfo"
android:scrollbars="vertical"
android:layout_alignParentLeft="true" …Run Code Online (Sandbox Code Playgroud) 所以我有一个奇怪的问题,我不完全确定我应该提供的所有信息,但我会尽我所能 - 如果我需要添加更多信息,请告诉我.我有,当我完成我的一个问题Activity,并返回到前一个Activity(或一个新的启动它Intent-这个问题似乎在整理为中心Activity)的UI性能急剧下降约六,七秒钟,然后返回到正常.
从LogCat,此警告始终显示:
07-11 22:09:42.594: W/ActivityManager(292): Launch timeout has expired, giving up wake lock!
07-11 22:09:42.601: W/ActivityManager(292): Activity idle timeout for ActivityRecord{42bf6e00 com.kcoppock.sudokubeta/com.kcoppock.sudoku.SudokuBoardActivity}
Run Code Online (Sandbox Code Playgroud)
一旦活动超时,UI性能就会恢复正常.在那之前,它非常缓慢.我没有可以阻止主线程的代码,我甚至已经注释掉了我的整个onPause()方法,看它是否有任何区别,但事实并非如此.
在Activity没有任何产卵后台线程,不执行任何网络活动,它具有唯一的磁盘访问的一些访问SharedPreferences.我之前能够找到的问题是关于空闲超时HistoryRecord,而不是ActivityRecord.
任何想法会导致什么?或者我如何确定阻止UI线程的内容,如果发生了什么?
编辑:好的,只是尝试注释掉除super.onCreate()和setContentView()之外的所有内容 - 问题仍然存在.它不与任何其他活动,但这个发生,但有什么可这一个.:/
我编写了一个XML代码,我想要扩展EditText以适应父宽度.花了这么多时间后,我找不到扩展EditText的方法.
这是我的XML:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableRow
android:layout_marginLeft="10dp"
android:layout_marginBottom="15dip">
<TextView
android:text="Comment"
android:layout_width="match_parent"
android:textStyle="bold"
android:padding="3dip" />
</TableRow>
<TableRow
android:layout_marginLeft="10dp"
android:layout_marginBottom="15dip">
<EditText
android:id="@+id/EditText02"
android:layout_height="wrap_content"
android:lines="5"
android:gravity="top|left"
android:inputType="textMultiLine"
android:scrollHorizontally="false"
android:minWidth="10.0dip"
android:maxWidth="5.0dip"/>
</TableRow>
<TableRow
android:layout_marginLeft="10dp"
android:layout_marginBottom="15dip"
android:gravity="center">
<Button
android:id="@+id/cancel"
android:text="Next" />
</TableRow>
</TableLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么.请帮我.
我有自己的样式用于定义为主题的按钮,但我也使用自己的类来处理按钮(因为自己的字体).可以用一个漂亮的名字来调用我的按钮,例如
<MyButton>
Run Code Online (Sandbox Code Playgroud)
代替
<com.wehavelongdomainname.android.ui.MyButton>
Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法,允许用户按下按钮浏览SD卡的内容,然后选择一个文件夹,其路径将返回给应用程序.类似于在Windows上启动"浏览..."对话框以进行安装.
我想创建一个布局,顶部和底部有一个水平LinearLayout,中间有一个ListView填充.
我该如何定义main.xml.
我尝试在顶部创建一个水平LinearLayout的布局,底部是TextView,中间是ListView填充; 没关系.但在我将底部TextView修改为LinearLayout后,底部的LinearLayout消失了.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:textSize="12px"
android:text="something here"
android:layout_width="50px"
android:layout_height="wrap_content"
/>
<TextView
android:textSize="12px"
android:text="something here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
>
<ListView
android:id="@+id/listbody"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:textSize="12px"
android:text="50%"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:textSize="12px"
android:text="50%"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
有人可以告诉你吗?请帮忙.
所以,我有点期待这最终成为一个简单的答案,但我现在已经黑了一段时间了,似乎无法解决这个问题.所以我有一个特定的类,Intersection当包含在任何其他标题中时,我会:
error C2061: syntax error : identifier 'Intersection'
这是我的交叉头:
#ifndef INTERSECTION_H
#define INTERSECTION_H
#include "Coord.h"
#include "Road.h"
#include "TrafficLight.h"
class Intersection {
private:
int id;
Coord * midPoint;
Road * northRoad;
Road * eastRoad;
Road * westRoad;
Road * southRoad;
TrafficLight * trafficLight;
public:
Intersection(int, Coord *, Road *, Road *, Road *, Road *);
~Intersection();
void transitionTrafficLight();
int getId();
Road * getNorthRoad();
Road * getEastRoad();
Road * getWestRoad();
Road * getSouthRoad();
TrafficLight * getTrafficLight();
};
#endif
Run Code Online (Sandbox Code Playgroud)
现在,如果我尝试在其他地方使用此类,我会收到错误.例如: …
我有一个巨大的文本文件,其中记录由字符串MSH标识.
我需要找到第200条记录.我希望有一个正则表达式,我可以在Notepad ++中使用,这将使我能够找到第200次出现的字符串MSH.
因此,我试图了解如何在View持久动画的自定义中正确使用硬件加速(如果可用).这是我的基本前提onDraw():
canvas.drawColor(mBackgroundColor);
for (Layer layer : mLayers) {
canvas.save();
canvas.translate(layer.x, layer.y);
//Draw that number of images in a grid, offset by -1
for (int i = -1; i < layer.xCount - 1; i++) {
for (int j = -1; j < layer.yCount - 1; j++) {
canvas.drawBitmap(layer.bitmap, layer.w * i, layer.h * j, null);
}
}
//If the layer's x has moved past its width, reset back to a seamless position
layer.x += ((difference * layer.xSpeed) …Run Code Online (Sandbox Code Playgroud) 我在XML文件中的AbsoluteLayout中有一个按钮.从那里我可以设置按钮的(x,y)位置.
如何以编程方式获取和设置按钮的(x,y)坐标?
谢谢大家.
android ×8
performance ×2
android-view ×1
c++ ×1
coordinates ×1
fill-parent ×1
java ×1
layout ×1
notepad++ ×1
regex ×1
scroll ×1
syntax-error ×1
textview ×1