十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Dialog类
创新互联建站-专业网站定制、快速模板网站建设、高性价比绛县网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式绛县网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖绛县地区。费用合理售后完善,十载实体公司更值得信赖。public class TestDialog extends DialogFragment implements View.OnClickListener{ TextView textView; EditText editText; Button button_save; Button button_dismiss; Button button_help; public static TestDialog newInstant(String prompt) { TestDialog td = new TestDialog(); Bundle bundle = new Bundle(); bundle.putString("prompt", prompt); td.setArguments(bundle); return td; } public void onClick(View arg0) { OnDialogDoneListener act = (OnDialogDoneListener) getActivity(); if(arg0.getId() == R.id.btn_dismiss) { act.onDialogDone(getTag(), true, null); dismiss(); return; } if(arg0.getId() == R.id.btn_help) { } if(arg0.getId() == R.id.btn_save) { // TextView v = (TextView)getView().findViewById(R.id.textView); act.onDialogDone(getTag(), false, editText.getText()); dismiss(); return; } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.dialog, container, false); textView = (TextView)v.findViewById(R.id.promptmessage); editText = (EditText)v.findViewById(R.id.inputtext); button_save = (Button)v.findViewById(R.id.btn_save); button_dismiss = (Button)v.findViewById(R.id.btn_dismiss); button_help = (Button)v.findViewById(R.id.btn_help); button_save.setOnClickListener(this); button_dismiss.setOnClickListener(this); button_help.setOnClickListener(this); return v; }
activity实现自定义的一个借口,与Dialog类交互
public interface OnDialogDoneListener { public void onDialogDone(String tag, boolean cancel, CharSequence message); }
activity类:
public class MainActivity extends Activity implements OnDialogDoneListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. // getMenuInflater().inflate(R.menu.main, menu); super.onCreateOptionsMenu(menu); menu.add(0, 0, 0, "dialog"); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Auto-generated method stub switch(item.getItemId()) { case 0: testDialog(); } return super.onOptionsItemSelected(item); } @TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") private void testDialog() { TestDialog td = TestDialog.newInstant("xia"); FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); td.show(ft, "Test Dialog"); } public void onDialogDone(String tag, boolean cancel, CharSequence message) { String s = tag + "responds with : " + message; if(cancel) { s = tag + " was cancelled by the user"; } Toast.makeText(this, s, Toast.LENGTH_LONG); Log.v("log_debug", s); } }
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。