增加按钮和监听,这个和上个不同在于,它不是在一个dialog里面,而是从新写了一个activity,因此需要先找到这个activity的入口。
case R.id.checkframe: if (mCurrentModule instanceof PhotoModule) { PhotoUI ui = ((PhotoModule) mCurrentModule).getPhotoUIInstance(); if (ui != null) { PhotoFrameUpdateManager photoFrameManager = new PhotoFrameUpdateManager(CameraActivity.this, ui); if (photoFrameManager.isNetworkConnected()) { // photoFrameManager.checkUpdate(); startActivityForResult(new Intent(CameraActivity.this, KuangDownloadActivity.class), REQ_CODE_DOWNLOAD); } else { photoFrameManager.showNetworkDialog(); } } } break;
公共监听类中的checkframe,找到之后,看到
startActivityForResult(new Intent(CameraActivity.this, KuangDownloadActivity.class), REQ_CODE_DOWNLOAD);建立一个新的activity,名字叫KuangDownloadActivity,点击进入,然后先改布局文件,
看到setContentView(R.layout.kuang_download_main);点击进入
<RelativeLayout style="@style/KuangTopbar" > <TextView style="@style/KuangTopbar_text" android:text="@string/photoframe_check" /> <Button android:id="@+id/backbutton2" android:layout_width="@dimen/about_title_height" android:layout_height="@dimen/about_title_height" android:layout_centerVertical="true" android:layout_marginLeft="@dimen/about_title_btn_margin_left" android:background="@drawable/about_back" /> </RelativeLayout>
其中style="@style/KuangTopbar"定义了一个style点击可对style进行修改
<style name="KuangTopbar"> <item name="android:gravity">center_vertical</item> <item name="android:orientation">horizontal</item> <item name="android:background">@drawable/photoframe_title</item> <item name="android:paddingLeft">5dip</item> <item name="android:paddingRight">5dip</item> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">48dp</item> </style>
修改完毕回到activity进行修改增加按钮搞定。
protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.kuang_download_main); kuangList = (ListView) findViewById(R.id.viewBookList); adapter = new KuangItemAdapter(this,kuangList); loadStateView = (LoadStateView) findViewById(R.id.downloadStatusBox); Button backbutton2 = (Button) findViewById(R.id.backbutton2); backbutton2.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { finish(); } });
返回上层菜单,直接finish();就好
时间: 2024-10-13 00:16:46