法一:我在TextView设置点击属性
<TextView
android:id="@+id/id_registerTV"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:onClick="Lregister"
android:text="立即注册 >"
android:textColor="#489cfa"
android:textSize="20sp"
/>
然后写了点击事件,但是没反应
public void Lregister(View view)
{
// TODO Auto-generated method stub
Toast.makeText(UserLogin.this, "赶紧注册", Toast.LENGTH_LONG)
.show();
Intent mainIntent = new Intent(UserLogin.this,
UserRegister.class);
startActivity(mainIntent);
}
法二:但是我用点击监听事件却可以
registerTV.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
Toast.makeText(UserLogin.this, "赶紧注册", Toast.LENGTH_LONG)
.show();
Intent mainIntent = new Intent(UserLogin.this,
UserRegister.class);
startActivity(mainIntent);
}
});
|
|