Exemplo n.º 1
0
  private void displayListView() {

    dbHelper.expireTraining(); // ADDED VIKALP CONTENT EXPIRY
    Cursor cursor = dbHelper.fetchAllTraining();

    // The desired columns to be bound
    String[] columns =
        new String[] {
          AnnounceDBAdapter.KEY_TITLE, AnnounceDBAdapter.KEY_DETAIL, AnnounceDBAdapter.KEY_SUMMARY
        };

    // the XML defined views which the data will be bound to
    int[] to = new int[] {R.id.tvTListTitle, R.id.tvTListDetail, R.id.tvListSummary};

    // create the adapter using the cursor pointing to the desired data
    // as well as the layout information
    dataAdapter = new TrainingAdapter(this, R.layout.trainlisting, cursor, columns, to);

    listView = (ListView) findViewById(R.id.listViewT);
    // Assign adapter to ListView
    listView.setAdapter(dataAdapter);
    registerForContextMenu(listView);

    listView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> listView, View view, int position, long id) {

            itemView(position);
          }
        }); // onClick
  } // end of displayList
Exemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.trainlist);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      if (!BuildVars.debug) {
        getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
      }
    }
    NotificationManager mNotificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancelAll();
    search = (ImageButton) findViewById(R.id.sample_button);
    search.setOnTouchListener(myhandler2);
    nomobcast = (TextView) findViewById(R.id.noNew);
    sample_refresh = (ImageButton) findViewById(R.id.sample_refresh);
    getPreferences(MODE_PRIVATE).edit().putString("listScroll", "0").commit();
    search.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent i = new Intent(TrainingListView.this, Search.class);
            i.putExtra("tablename", "Training");
            startActivity(i);
          }
        });

    sample_refresh.setOnTouchListener(myhandler2);
    sample_refresh.setOnClickListener(myhandler11);
    announce = new AnnounceDBAdapter(this);
    announce.open();
    if (announce.fetchAllTraining().getCount() < 1) {
      ConnectionDetector cd = new ConnectionDetector(getApplicationContext());

      Boolean isInternetPresent = cd.isConnectingToInternet(); //
      if (isInternetPresent) {
        myhandler11.onClick(sample_refresh);
      }
    }
    announce.close();
  }