TextView单击不会涵盖所有TextView

时间:2016-02-07 16:10:51

标签: android textview

我有一些文本,它存储在本地数据库中,我通过LISTVIEW显示它们,我为每个人做了一行,在Lisview的单行显示每个状态,我使用onListItemClick方法,我想要taht当点击每一行时,应该弹出一个共享菜单,直到这里它是正确的但它只适用于该行的顶部而不是所有部分请告诉我如何使该行的所有部分都可点击。

这是类代码:

public class sharedlist extends ListActivity {

private String[] items;
private database db;

private Typeface homa;
private Typeface nazanin;
private SharedPreferences sp;
private Typeface god;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sharedlist);


    db=new database(this);
    db.open();

    items=new String[db.Count("content")];

    homa=Typeface.createFromAsset(getAssets(), "Font/homa.ttf");
    nazanin=Typeface.createFromAsset(getAssets(), "Font/nazanin.ttf");
    god=Typeface.createFromAsset(getAssets(), "Font/Godfather.ttf");
    sp=getApplicationContext().getSharedPreferences("setting", 0);

    setListAdapter(new AAD());


}



@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, db.Display_Shared(position, 2).toString());
    startActivity(Intent.createChooser(sharingIntent,"اشتراک گذاری از طریق"));

}

class AAD extends ArrayAdapter{

    public AAD(){
        super(sharedlist.this , R.layout.row,items);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater in=getLayoutInflater();
        View row=in.inflate(R.layout.row, parent, false);

        TextView username= (TextView) row.findViewById(R.id.row_username);
        TextView maintext= (TextView) row.findViewById(R.id.row_maintext);

        username.setText(db.Display_Shared(position,1).toString());
        maintext.setText(db.Display_Shared(position, 2).toString());

        username.setTypeface(god);

        if(sp.getString("font", "homa").equals("nazanin")){


            maintext.setTypeface(nazanin);


        }else if(sp.getString("font", "homa").equals("homa")){

            maintext.setTypeface(homa);

        }


        if(sp.getString("size", "k").equals("k")){

            maintext.setTextSize(18);

        }else if(sp.getString("size", "k").equals("b")){

            maintext.setTextSize(25);

        }
        return (row);
    }
}

/*@Override
protected void onPause() {
    super.onPause();
    db.close();
}*/


}

这里是行部分XML文件代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="نام کاربری"
    android:id="@+id/row_username"
    android:layout_marginTop="19dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="10dp"
    android:gravity="left"
    android:textColor="#000000" />

 <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="متن اصلی"
    android:id="@+id/row_maintext"
    android:layout_below="@+id/row_username"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_marginTop="15dp"
    android:layout_marginRight="10dp"
    android:gravity="right"
    android:layout_marginLeft="10dp"
    android:lineSpacingMultiplier="1.5"
    android:textSize="12dp"
    android:clickable="true"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:enabled="false"
    android:longClickable="false"
    android:linksClickable="false"
    android:textColor="#000000"
    android:elegantTextHeight="false"
    android:inputType="textMultiLine"
    android:nestedScrollingEnabled="false" />
  </RelativeLayout>

0 个答案:

没有答案