如何将marquee应用于android文本视图 我的选框不起作用,我在这里犯了错误是我的代码请帮我解决这个问题:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout2"
android:layout_alignRight="@+id/linearLayout2"
android:layout_below="@+id/linearLayout2"
android:layout_marginTop="30dp" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/edt_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPassword"
android:hint="@string/password_hint"
android:gravity="center">
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout1"
android:layout_alignRight="@+id/linearLayout1"
android:layout_below="@+id/linearLayout1"
android:layout_marginTop="111dp" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user_name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/edt_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:hint="@string/user_name_hint" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="570dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/Login_title"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout3"
android:layout_alignRight="@+id/linearLayout3"
android:layout_below="@+id/linearLayout3"
android:layout_marginTop="60dp" >
<Button
android:id="@+id/btn_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.71"
android:text="@string/clear" />
<Button
android:id="@+id/btn_signin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.70"
android:text="@string/signin" />
</LinearLayout>
</RelativeLayout>
这是我的java代码orshould我应用动态标记:
package com.example.demo2c1testpanel;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Iterator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbRequest;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Loginpage extends Activity
{
public static final int targetVendorID = 6790;
public static final int targetProductID = 29987;
HashMap<String, UsbDevice> devicelist= null;
public UsbManager manager;
public UsbDeviceConnection usbDeviceConnection;
public UsbInterface usbInterfaceFound = null;
public UsbEndpoint endpointOut = null;
public UsbEndpoint endpointIn = null;
public UsbDevice usbdevice,device_details;
Button clear,signin;
EditText username,password;
String i = "";
Intent i2;
String User_Name=null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.loginpage);
username = (EditText)findViewById(R.id.edt_username);
username.setSelection(0);
password = (EditText)findViewById(R.id.edt_password);
signin = (Button)findViewById(R.id.btn_signin);
signin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
{
check_connection();
}
}
});
}
public void check_connection()
{
int i,j;
String as[];
User_Name=username.getText().toString();
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
i = deviceList.size();
if(i==0)
{
Toast.makeText(Loginpage.this,"Device Not Connected",Toast.LENGTH_LONG).show();
return;
}
as = new String[i];
deviceList.keySet().toArray(as);
for(j=0;j<i;j++)
{
device_details = (UsbDevice)deviceList.get(as[j]);
if((device_details.getVendorId()==targetVendorID) && (device_details.getProductId()==targetProductID))
{
Toast.makeText(Loginpage.this,"Device Connected",Toast.LENGTH_LONG).show();
if(User_Name.toLowerCase().equals("medequip") && password.getText().toString().equals("medequip"))
{
i2 = new Intent(Loginpage.this,TestsPage.class);
startActivity(i2);
}
else
{
Toast.makeText(Loginpage.this,"Invalid username and password", Toast.LENGTH_LONG).show();
}
}
}
}
}
答案 0 :(得分:0)
尝试这样:
<TextView
android:text="START | lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00 | lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00 | END"
android:id="@+id/MarqueeText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true">