Activity设置为启动页面点击才有效,不然点击无效

imven7 2016-03-05 03:47:42
小弟我现在遇到一个问题,就是在一个原有的项目上加上一个功能,点击一个Activity跳转到另一个Activity,原本是一个很简单的问题,但是就是不知道为什么点击Activity没反应,我在XML文件中设置了clickable="ture"
<RelativeLayout
android:id="@+id/re_gouwu"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="20dp"
android:background="@drawable/btn_list_item_bg"
android:clickable="true"
android:paddingLeft="12dp" >

<ImageView
android:id="@+id/iv_gouwu"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="12dp"
android:src="@drawable/find_gouwu" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@id/iv_gouwu"
android:text="@string/shopping"
android:textColor="#353535"
android:textSize="16sp" />

<View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:layout_alignParentBottom="true"
android:layout_marginRight="12dp"
android:background="#dadada" />
</RelativeLayout>


在androidMainifest.xml文件中注册了Activity,
<activity
android:name="com.fanxin.link.GotoweekendActivity">
</activity>


在.JAVA文件中设置了监听事件

public class GotoweekendActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_find);

RelativeLayout rtl = (RelativeLayout) findViewById(R.id.re_gouwu);
rtl.setOnClickListener(new rtlOnClickListener());
}

class rtlOnClickListener implements OnClickListener{
public void onClick(View v)
{
Intent intent = new Intent();
intent.setClass(GotoweekendActivity.this, ToweekendActivity.class);
GotoweekendActivity.this.startActivity(intent);
}
}


这个Activity复制到其他项目时是能顺利运行的,但是在本项目就无效,而且是在本项目所有新开发的Activity活动都是无效的,但是原有的项目中的Activity却是有效的.

而且我发现一个问题,就是把先开发的Activity的java文件设为启动页面时,本Activity是有效的,能跳转,但是相同页面的其他Activity却是无效的,我困扰差不多一星期了,一直找不到问题的所在,求解答
...全文
298 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fishle123 2016-03-07
  • 打赏
  • 举报
回复
TwowekendActivity没有在manifest.xml中注册
xingzhong128 2016-03-06
  • 打赏
  • 举报
回复
ToweekendActivity这个ancitvyt你注册了吗?
xingzhong128 2016-03-06
  • 打赏
  • 举报
回复
Intent intent = new Intent(); intent.setClass(GotoweekendActivity.this, ToweekendActivity.class); 你把这个两句写成一句 Intent intent = new Intent(GotoweekendActivity.this, ToweekendActivity.class); 试试?
VNanyesheshou 2016-03-05
  • 打赏
  • 举报
回复
你写的有点乱,是不是在清单文件里没有配置第二个页面。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧