2013-05-28 1 views
-3

는 다음 목록보기자동 클릭 하나 개의 항목을 경우 내가 MySQL 데이터베이스에서 일부 데이터를 검색하는 것을 시도하고있다

1 개 이상의 결과가 발견되면, 그 중 하나를 클릭하면 이동하게됩니다를 표시 그것의 각각의 세부 사항 페이지.

그러나 .. 목록보기에서 하나의 결과 만있는 경우 세부 정보 페이지로 직접 이동하려고합니다. 간단히 말해서 목록에 하나의 항목 만있는 경우 자동으로 목록보기에서 onItemClick을 호출합니다. 당신은 결과 집합의 수를 알게되면

@Override 
public void onItemClick(AdapterView<?> parent, View view, int position, 
     long id) { 

    // when a student is selected then the following methods are called 

    DetailsFragment.setLUNCH_TYPE(searchResult.get(position).lunchtype); 
    Log.d("Lunch type selected", ""+DetailsFragment.getLUNCH_TYPE()); 
    ((HomeActivity) getActivity()).startStudentSale(searchResult 
      .get(position).name.toString(),searchResult 
      .get(position).isStudent,searchResult.get(position).id); 

    // it was comming null here when running this this need to find out why 
    // ((HomeActivity)getActivity()).setmSaleType(SALE_TYPE.SEARCHED_STUDENT); 
} 
+4

한 경우 해당 단지에 대한 onclick을 호출 할 필요는 없습니다 :

내 목록보기의 onClickItemListener은 다음과 같습니다 데이터 소스의 크기를 확인하고 크기가 == 1 인 경우에는 onclick에서 호출하는 ur 메서드 만 호출하십시오. – NaserShaikh

+0

그렇게하면 나에게 불법적 인 예외가 발생합니다. – Bora

+0

super.onBackPressed(); 조각을 숨기려면? – Bora

답변

0

는, CNT 말을하고, 즉,

if(cnt==1){ 
    Intent intent=new Intent(getApplicationContext(),DetailActivity.class); 
    startActivity(intent); 
    } 
+0

그렇게하면 나에게 불법적 인 예외를주는 것 – Bora

+0

나는 super.onBackPressed()를 호출해야했다; 조각을 숨기려면? – Bora

+0

프로 그램의 어느 부분에서이 작업을 수행하고 있습니까? – Sanghita

관련 문제