我知道这听起来很容易.我需要在中心放置一个文本,但是当文本太长时,它需要在下面,但仍然在我的xml的中心对齐.
这是我的代码:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/showdescriptioncontenttitle"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_centerHorizontal="true"
>
<TextView
android:id="@+id/showdescriptiontitle"
android:text="Title"
android:textSize="35dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我把paddingTop和Bottom放在一边因为我需要一些空间.PS:我的代码更大; 它在RelativeLayout中.
由于条款的变化,Parse现在限制请求的数量,这是一件好事,但Parse Push和Parse Analytics会被视为请求吗?
我试图改变应用程序的构建,现在eclipse不起作用.
控制台中没有任何内容,当我启动调试时,日志中没有任何内容.
我刚收到这条消息:
[2011-03-31 11:22:58 - Logcat]device not found
com.android.ddmlib.AdbCommandRejectedException: device not found
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:736)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:373)
at com.android.ddmlib.Device.executeShellCommand(Device.java:284)
at com.android.ddmuilib.logcat.LogPanel$3.run(LogPanel.java:527)
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" <TextView android:id="@+id/tv_test" android:text="Test " android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ListView android:id="@+id/list_test" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@id/tv_test" ></ListView> </RelativeLayout>
一切都在ScrollView中,我不知道为什么但相对布局似乎设置了一个包装内容.它使ListView变小,而不是占据整个地方.
我不知道它是否有用,但这是我的java代码:
public class ShowView extends Activity{
ListView lv;
ArrayAdapter<String> adapter;
String[] myList = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Height", "Nine", "Ten"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.show);
lv = (ListView) findViewById(R.id.list_test);
adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, myList);
adapter.setDropDownViewResource(android.R.layout.simple_list_item_1);
lv.setAdapter(adapter);
}
}
Run Code Online (Sandbox Code Playgroud) 我知道如何登录:
ParseTwitterUtils.logIn(loginView.getCurrentContext(), new LogInCallback() {
@Override
public void done(ParseUser parseUser, ParseException e) {
if (e == null) {
String welcomeMessage = "";
if (parseUser.isNew()) {
welcomeMessage = "Hello new guy!";
} else {
welcomeMessage = "Welcome back!";
}
loginView.showLoginSuccess(parseUser, welcomeMessage);
} else {
String errorMessage = "Seems we have a problem : " + e.getLocalizedMessage();
loginView.showLoginFail(errorMessage);
}
}
});
Run Code Online (Sandbox Code Playgroud)
并注销:
ParseUser.logOutInBackground(new LogOutCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
homeView.goLogin(true, "See you soon");
} else …Run Code Online (Sandbox Code Playgroud) 我正在创建一个自定义drawable(它从Drawable扩展),我正在尝试对它进行阴影效果.
这是我的代码的一部分:
public void draw(Canvas canvas) {
Path path = new Path();
path.moveTo(0, 0);
path.lineTo(0, Y/2);
path.lineTo(X/2, Y);
path.lineTo(X, Y/2);
path.lineTo(X, 0);
path.lineTo(0, 0);
Paint paint = new Paint();
paint.setColor(context.getResources().getColor(R.color.red_dark));
paint.setStyle(Style.FILL_AND_STROKE);
paint.setStrokeWidth(2f);
paint.setShadowLayer(1, 0, 10f, context.getResources().getColor(R.color.black));
canvas.drawPath(path, paint);
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,但它把相同颜色的阴影,我仔细检查了一切,我没有看到问题所在.我在星系纽带上测试它.但在模拟器上它工作得很好.
我想在我的ViewPager的每个页面中放置图像(就像一本书).这些图片来自网址列表:
我的适配器看起来像这样:
private class MyPagerAdapter extends PagerAdapter{
@Override
public int getCount() {
return NUM_AWESOME_VIEWS;
}
/**
* Create the page for the given position. The adapter is responsible
* for adding the view to the container given here, although it only
* must ensure this is done by the time it returns from
* {@link #finishUpdate()}.
*
* @param container The containing View in which the page will be shown.
* @param position The page position to be instantiated.
* …Run Code Online (Sandbox Code Playgroud) android image android-asynctask android-viewpager android-pageradapter
为什么Eclipse在已经打开模拟器的情况下打开一个新的模拟器?有时它会发生,有时它不会发生.有人知道为什么吗?我讨厌什么时候不这样,我想解决这个"问题"
我有一个从简单的手势扩展而来的类,我正在使用 onfling 方法:
class MyGestureListener extends GestureDetector.SimpleOnGestureListener{
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
// TODO Auto-generated method stub
float e1_X = e1.getX();
float e1_Y = e1.getY();
float e2_X = e1.getX();
float e2_Y = e2.getY();
if(velocityX > 0 && velocityX > velocityY){
text.setText("Swipe left");
}else if(velocityX < 0 && velocityX < velocityY){
text.setText("Swipe right");
}else if(velocityY < 0 && velocityX > velocityY){
text.setText("Swipe down");
}else if(velocityY > 0 && velocityX < velocityY){
text.setText("Swipe up");
} …Run Code Online (Sandbox Code Playgroud) 我正试图检测我周围的信标,但使用Nearby API,我似乎无法找到它们.
我正在使用此方法来检测附近的设备:
public void startDiscovery(String serviceId, final OnDiscoveryListener l) {
Nearby.Connections.startDiscovery(googleApiClient, serviceId, Connections.DURATION_INDEFINITE, new Connections.EndpointDiscoveryListener() {
@Override
public void onEndpointFound(String endpointId, String deviceId, String serviceId, String endpointName) {
if (l != null) {
l.onEndpointFound(endpointId, deviceId, serviceId, endpointName);
}
}
@Override
public void onEndpointLost(String s) {
if (l != null) {
l.onEndpointLost(s);
}
}
})
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (l != null) {
l.onResult(status);
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
听众看起来像这样:
public interface OnDiscoveryListener {
public …Run Code Online (Sandbox Code Playgroud)