小编Aft*_*Ali的帖子

如何在由BaseAdapter获取视图方法扩展的类中显示Toast

当我单击列表视图中的按钮时,我有显示Toast消息的问题.问题是我通过BaseAdapter扩展的自定义类我有一个名为GetView的方法我想显示来自该特定消息的Toast消息

以下是我的Listview Row Xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/tools"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    app:context=".HomeActivity" >

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TableRow
            android:id="@+id/tableRow_laugh"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:ignore="UselessParent" >

                <TableLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentTop="true" >

                    <TableRow
                        android:id="@+id/tableRow_Header_laugh"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:background="#818085" >

                        <RelativeLayout
                            android:id="@+id/relative_header"
                            android:layout_width="wrap_content"
                            android:layout_height="fill_parent"
                            android:background="#818085" >

                            <ImageView
                                android:id="@+id/UserIconPic_laugh"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentLeft="true"
                                android:layout_alignParentTop="true"
                                android:layout_weight="0.4"
                                android:src="@drawable/ic_launcher"
                                app:ignore="ObsoleteLayoutParam,ContentDescription" />

                            <Button
                                android:id="@+id/btn_Vote_laugh"
                                android:layout_width="wrap_content"
                                android:layout_height="match_parent"
                                android:layout_alignParentRight="true"
                                android:layout_alignParentTop="true"
                                android:layout_weight=".4"
                                android:text="VOTE"
                                app:ignore="ObsoleteLayoutParam,HardcodedText" />

                            <TextView
                                android:id="@+id/txt_number_of_vote_laugh"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignBaseline="@+id/btn_Vote_laugh"
                                android:layout_alignBottom="@+id/btn_Vote_laugh"
                                android:layout_toRightOf="@+id/UserIconPic_laugh"
                                android:layout_weight=".4"
                                android:textAppearance="?android:attr/textAppearanceMedium"
                                app:ignore="ObsoleteLayoutParam,HardcodedText" />
                        </RelativeLayout>
                    </TableRow>

                    <TableRow
                        android:id="@+id/tableRow_MainText_laugh"
                        android:layout_width="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android listview android-layout baseadapter listview-adapter

9
推荐指数
1
解决办法
2万
查看次数

java.lang.NumberFormatException:无法将String解析为整数

当我遇到这个问题时,我正在研究我的android项目

我希望这将像"0345303709"7这样的字符串转换为整数,但我不断得到NumberFormatException.

我在这里搜索了所有问题,但没有找到解决我问题的方法.

以下是我的Android代码:

 String edit_cell=cellnumber.getText().toString();
        try
        {
            if(cellnumber.getText().length()==11 && TextUtils.isEmpty(edit_cell)!=true && edit_cell!=null)
            {

                cell=Integer.valueOf("03462651882");
            }
            else
            {                   
                Toast.makeText(this, "Invalid CellNumber\n Write CellNumber like this Format:\nNetworkCode Followed by your Number\n",Toast.LENGTH_LONG).show();
                Toast.makeText(this, "eg:03213213214",Toast.LENGTH_LONG).show();    
            }
        }

        catch(Exception ex)
        {
            Toast.makeText(this, "Invalid cellnumber\n Write cellNumber line this format:\n Network code followed by your number\n",Toast.LENGTH_LONG).show();
            Toast.makeText(this, "eg:03213213214",Toast.LENGTH_LONG).show();    
        }      
Run Code Online (Sandbox Code Playgroud)

我使用的是eclipse Helios IDE和Android版本是2.2 api 8

java android exception-handling type-conversion

4
推荐指数
2
解决办法
4771
查看次数