1,使用list进行界面的设计
先上代码
package nfc.com.mytelephone.dialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
import nfc.com.mytelephone.R;
public class NewDialogActivity extends AppCompatActivity {
private ListView mListview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_dialog);
initView();
}
private void initView(){
mListview = (ListView) findViewById(R.id.listview);
mListview.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_expandable_list_item_1,getData()));
mListview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position){
case 0:
startActivity(new Intent(NewDialogActivity.this, AllDialogActivity.class));
break;
case 1:
startActivity(new Intent(NewDialogActivity.this, LinkTextActivity.class));
break;
case 2:
startActivity(new Intent(NewDialogActivity.this, DrawFocusRectActivity.class));
break;
}
}
});
}
private List<String> getData(){
List<String> data = new ArrayList<>();
data.add("所有弹框");
data.add("TextView文本识别,点击并跳转");
data.add("动态画矩形框,焦点框");
return data;
}
}
2,界面进行开发
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".dialog.NewDialogActivity">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
3,完成,且存在点击事件