{
Toast.makeText(getApplicationContext(), R.string.user_hint, 3000).show();
// TODO Auto-generated method stub
}
});
AlertDialog adAlertDialog=buliBuilder.create();
adAlertDialog.show();
}
else
{
String password=pswEditText.getText().toString();
Bundle bundle=new Bundle();
bundle.putString("username", username);
bundle.putString("password", password);
Intent intent=new Intent();
intent.setComponent(cn);
intent.putExtras(bundle);
startActivity(intent);
// TODO Auto-generated method stub
}
}
});
btn_login.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
ComponentName cn=new ComponentName(MainActivity.this,"com.example.test_intent.login");
String username=userEditText.getText().toString();
if(isEmpty(username))
{
buliBuilder.setMessage("用户名不能为空!").setPositiveButton("确定", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
Toast.makeText(getApplicationContext(), R.string.user_hint, 3000).show();
// TODO Auto-generated method stub
}
});
AlertDialog adAlertDialog=buliBuilder.create();
adAlertDialog.show();
}
else
{
String password=pswEditText.getText().toString();
Bundle bundle=new Bundle();
bundle.putString("username", username);
bundle.putString("password", password);
Intent intent=new Intent();
intent.setComponent(cn);
intent.putExtras(bundle);
startActivity(intent);
// TODO Auto-generated method stub
}
}
});
[java]
public static boolean isEmpty( String input )
{
if ( input == null || "".equals( input ) )
return true;
for ( int i = 0; i < input.length(); i++ )
{
char c = input.charAt( i );
if ( c != ' ' && c != '\t' && c != '\r' && c != '\n' )
{
return false;
}
}
return true;
}
public static boolean isEmpty( String input )
{
if ( input == null || "".equals( input ) )
return true;
for ( int i = 0; i < input.length(); i++ )
{
char c = input.charAt( i );
if ( c != ' ' && c != '\t' && c != '\r' && c != '\n' )
{
return false;
}
}
return true;
}
这样就可以了.
给个截图
这样就可以识别转义字符带来的麻烦。