同为 小白 Toast第三个参数不应该是个枚举类型的值吗 Toast.LENGTH_LONG等  整形数可以作为参数吗? 

解决方案 »

  1.   

    回复2楼~Toast.makeText(this, "登陆成功",Toast.LENGTH_LONG).show();这样子的我试过 同样不可以 可以用数字,我以前用的就可以
      

  2.   

    这个Toast有什么问题吗?
      

  3.   

    Toast.makeText(Splash.this, "neirong", 0).show();
    这样试试
      

  4.   

    Toast.makeText(MainActivity .this,"用户名或密码错误",1).show(); 
    要这样,有时候那些不显示的问题都是访问不到this,你只需要把this改成类.this,应该可以解决这个问题
      

  5.   

    创建的Activity继承ActionBarActivity ,是不是用了最新的SDK 呢?最新的SDK和旧版本的区别在于创建的Activity继承的不同,以前的是Activity,现在的是ActionBarActivity,为了版本兼容的,你新建项目时最低版本选择4.0以上,就不会出现appcompat_v7包,AndroidBarActivity是支持库里的类可以兼容2.x版本 activity提供的actionbar只有在3.0以上才可以用。
    你试下把Toast.makeText(this, "hello", 1).show();this换成MainActivity.this或者getApplicationContext()。
      

  6.   

    还是不可以 会不会是xml布局上存在覆盖呢?大神们帮我看下好么?
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:orientation="vertical"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.loginle.MainActivity" >    <TextView
            android:id="@+id/tv_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/input_name" />
       
        <EditText
            android:id="@+id/et_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/tv_name"
            android:layout_below="@+id/tv_name"
           
            android:ems="10"
            android:inputType="textPersonName" >
            <requestFocus />
        </EditText>   <TextView
            android:id="@+id/tv_pwd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/input_pwd" />    <EditText
            android:id="@+id/et_pwd"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/et_name"
            android:layout_below="@+id/tv_pwd"
           
            android:ems="10"
            android:inputType="textPassword" />    <CheckBox
            android:id="@+id/cb_save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/et_pwd"
            android:checked="true"
            android:layout_below="@+id/et_pwd"
            android:text="@string/save_pwd" />    <Button
            android:id="@+id/bt_login"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/cb_save"
          
            android:text="@string/loginla" /></LinearLayout>