The textual representation of the conflicting android

MY layout xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout 
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="3"
 >
<ImageView
    android:id="@+id/photo_user"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/user_pic"
    android:layout_gravity="top"
    android:contentDescription="@string/image_descrip"
    />
<TextView 
    android:id="@+id/text_user"
    android:layout_alignRight="@+id/photo_user"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/user_info"
    android:textColor="#FFFFFF"
    android:background="#AA000000"/>
   </RelativeLayout>
  <RelativeLayout 
  android:layout_width="match_parent"
  android:layout_height="0dip"
  android:layout_weight="7"
  android:background="#000000"
   >
<RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:paddingTop="10dp"
  android:paddingBottom="10dp"
    >
   <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:paddingLeft="15dp"
        android:text="@string/plan_text0"
        />
    <TextView 
        android:id="@+id/tv_viewplan"
        android:layout_width="wrap_content"
        android:paddingLeft="100dp"
        android:textSize="12sp"
        android:layout_height="wrap_content"
        android:text="@string/plan_text"
        />
    <TextView 
        android:id="@+id/tv_plan1"
        android:paddingLeft="215dp"
        android:textSize="12sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/plan_text1"
        />
  </RelativeLayout>
<View
    android:id="@+id/place_view1"
   android:layout_width="fill_parent"
   android:layout_height="2dp"
   android:layout_marginTop="40dp"
   android:background="#5C5C5C"
    />
 <RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
   android:layout_below="@+id/place_view1"
   android:paddingTop="10dp"
   android:paddingBottom="10dp"
    >
   <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:paddingLeft="15dp"
        android:text="@string/services_text0"
        />
    <TextView 
        android:id="@+id/tv_service"
        android:layout_width="wrap_content"
        android:paddingLeft="100dp"
        android:textSize="12sp"
        android:layout_height="wrap_content"
        android:text="@string/services_text"
        />
    <TextView 
        android:id="@+id/tv_service1"
        android:layout_below="@+id/tv_plan1"
        android:textSize="12sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="215dp"
        android:text="@string/services_text1"
        />
  </RelativeLayout>
   <View
   android:id="@+id/place_view2"
   android:layout_width="fill_parent"
   android:layout_height="2dp"
   android:layout_marginTop="80dp"
   android:background="#5C5C5C"
    />
   <RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
   android:layout_below="@+id/place_view2"
   android:paddingTop="10dp"
   android:paddingBottom="10dp"
    >
   <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:paddingLeft="15dp"
        android:text="@string/bill_text0"
        />
    <TextView 
        android:id="@+id/tv_bill"
        android:layout_width="wrap_content"
        android:paddingLeft="100dp"
        android:textSize="12sp"
        android:layout_height="wrap_content"
        android:text="@string/bill_text"
        />
    <TextView 
        android:id="@+id/tv_bill1"
        android:layout_below="@+id/tv_service1"
        android:paddingLeft="215dp"
         android:textSize="12sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/bill_text1"
        />
  </RelativeLayout>
 <View
   android:id="@+id/place_view3"
   android:layout_width="fill_parent"
   android:layout_height="2dp"
   android:layout_marginTop="120dp"
   android:background="#5C5C5C"
    />
   <RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
   android:layout_below="@+id/place_view3"
   android:paddingTop="10dp"
   android:paddingBottom="10dp"
    >
   <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:paddingLeft="15dp"
        android:text="@string/request_text0"
        />
    <TextView 
        android:id="@+id/tv_request"
        android:layout_width="wrap_content"
        android:paddingLeft="100dp"
        android:textSize="12sp"
        android:layout_height="wrap_content"
        android:text="@string/request_text"
        />
    <TextView 
        android:id="@+id/tv_request1"
        android:paddingLeft="215dp"
         android:textSize="12sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/request_text1"
        />
  </RelativeLayout>
  <View
   android:id="@+id/place_view4"
   android:layout_width="fill_parent"
   android:layout_height="2dp"
   android:layout_marginTop="160dp"
    />
  <RelativeLayout 
      android:layout_height="wrap_content"
      android:layout_width="match_parent"
      android:layout_below="@+id/place_view4"
      >
      <ExpandableListView 
          android:id="@+id/ex_notifi"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          ></ExpandableListView>

  </RelativeLayout>



   </RelativeLayout>
</LinearLayout>

      

and in my sherlock fragment class I have the same listener for all text views

      getView().findViewById(R.id.tv_viewplan).setOnClickListener(this);
  getView().findViewById(R.id.tv_plan1).setOnClickListener(this);
  getView().findViewById(R.id.tv_service).setOnClickListener(this);
  getView().findViewById(R.id.tv_service1).setOnClickListener(this);
  getView().findViewById(R.id.tv_bill).setOnClickListener(this);
  getView().findViewById(R.id.tv_bill1).setOnClickListener(this);
  getView().findViewById(R.id.tv_request).setOnClickListener(this);
  getView().findViewById(R.id.tv_request1).setOnClickListener(this);

      

in my onclick listener

   switch(v.getId())
  {
    case R.id.tv_viewplan:
        System.out.println("Plan ids"  +v.getId());
        title= "My Plan"; tag = "viewplan_dialog";
        Utilsdialog dialog_vwplan = new Utilsdialog(context, R.layout.child, title, tag);
        dialog_vwplan.show(fm, tag);
         break;
    case R.id.tv_plan1:
     System.out.println("Plan ids"  +v.getId());
        title= "Change plan"; tag = "changeplan_dialog";
        Utilsdialog dialog_chgplan = new Utilsdialog(context, R.layout.child,title, tag);
        dialog_chgplan.show(fm, tag);
         break;
    case R.id.tv_service:
        Toast.makeText(getActivity(), "SELECTED VIEW SERVICE", Toast.LENGTH_LONG).show();
         break;

    case R.id.tv_service1:
        Toast.makeText(getActivity(), "SELECTED ADD SERVICE", Toast.LENGTH_LONG).show();
         break;
    case R.id.tv_request:

        Toast.makeText(getActivity(), "SELECTED TRACK REQUEST", Toast.LENGTH_LONG).show();
         break;
    case R.id.tv_request1:

        Toast.makeText(getActivity(), "SELECTED ADD REQUEST", Toast.LENGTH_LONG).show();
         break;
    case R.id.tv_bill:

        Toast.makeText(getActivity(), "SELECTED VIEW BILL", Toast.LENGTH_LONG).show();
         break;
    case R.id.tv_bill1:

        Toast.makeText(getActivity(), "SELECTED PAY BILL", Toast.LENGTH_LONG).show();
         break;

     }

      

The problem is that tv_viewplan and tv_plan generate the same id and also for tv_service and tv_servive1 have the same id. therefore the switch causes the wrong block. I don't know how this is possible .... Help for help

+1


source to share


3 answers


different views with different name names do not have the same identifier over time. Never again. check that you have a different name for each view. There is an alternate method validation tag for each view where you must assign a unique tag for each view. but logically you have to work first.



0


source


You need to clean the project. 
If you are using eclipse then open your Project option in Menu, please find clean option in Submenu of Project.
Select your project and click ok button in popupwindow.
If you do like this then you can get new id to your project.
If you have any issues after clean the project let me know.


0


source


Clean and rebuild your project and make sure there are no duplicate IDs in each text view

if it doesn't work try this

why don't you just delete everything    getView().findViewById(R.id.tv_viewplan).setOnClickListener(this);

and add     android:onclick="clickText"

in every clickable text element

then add this function

 public void clickText(View v){
 //put your switch case here...
 }

      

0


source







All Articles