0

My Android Manifest file is like below and its not calling MainLauncher as a first activity instead of that its calling MultilevelTreeListView. I don't know the reason. I removed the below statement for MultiLeveltreelistview, but nothing appears in that case.

  <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.LAUNCHER" />

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jd.multileveltreelistview"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

       <activity
            android:name="com.jd.multileveltreelistview.MainLauncher"
            android:label="@string/app_name" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.jd.multileveltreelistview.MultilevelTreeListView"
            android:label="@string/hello_world" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

MainLauncher.Java

package com.jd.multileveltreelistview;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color; 
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;



public class MainLauncher extends Activity{
    LinearLayout lm;
    int i = 0;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


       ImageView imagePreview = (ImageView)findViewById(R.id.preview);
       //imagePreview.setImageResource(R.drawable.cigna);


        lm = (LinearLayout) findViewById(R.id.linearMain);
        lm.setBackgroundColor(Color.WHITE);

        TextView product3 = new TextView(this);
        product3.setText("\n");
        lm.addView(product3);  


        String[] ClearRow =  { "Enter" };
        LinearLayout InitRow = new LinearLayout(this);
           InitRow.setOrientation(LinearLayout.HORIZONTAL);
           createButtonsreset(InitRow, ClearRow, 1);

         TextView product2 = new TextView(this);
         product2.setText("           ");
            //product2.setTextColor(color.holo_blue_dark);
         lm.addView(product2);

         String[] ClearRow1 = { "Instructions" };
         LinearLayout InitRow1 = new LinearLayout(this);
         InitRow1.setOrientation(LinearLayout.HORIZONTAL);
         createButtonsreset(InitRow1, ClearRow1, 1);

             }

    @Override
    public void onBackPressed() {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);  
        this.finish();    
    }

    private void createButtonsreset(LinearLayout layoutToAddButtonsTo, String[] itemsToAdd, int Lengthvalue) {
        for (int i = 0; i < Lengthvalue; i++) {
            final Button buttonToAdd = new Button(this);
            buttonToAdd.setText("  "+itemsToAdd[i]);
            buttonToAdd.setCompoundDrawablePadding(10);
            buttonToAdd.setBackgroundResource(R.drawable.image);

            // buttonToAdd.setWidth(50);
           buttonToAdd.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {   
                    String Strvalue = (String) buttonToAdd.getText();
                    if (Strvalue.equals("  "+"Enter"))
                    {       DrawShapes1();   }
                   }
            });
           layoutToAddButtonsTo.addView(buttonToAdd);

        }
        // In the end add all buttons inside the inner LinearLayout to the outer LinearLayout.
        lm.addView(layoutToAddButtonsTo);
    }

    public void DrawShapes1() {
        Intent activityIntent = 
                new Intent(this, MainActivity.class);
        startActivity(activityIntent);
    }
}

And MultiLevelTreeview

package com.jd.multileveltreelistview;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
public class MultilevelTreeListView extends Activity 
{
    ListAdapter adapter;
    ListView mainList;
    ArrayList<Entity>arrTrades;
    public static int cnt = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.treelist);
        mainList=(ListView)findViewById(R.id.currentpending_list);
        mainList.setDividerHeight(10);
        arrTrades=new ArrayList<Entity>();
        mainList.setBackgroundResource(R.drawable.cigna);
    }

    @Override
    protected void onResume() 
    {
        if(arrTrades.size()==0){
            populateList();
        }
        super.onResume();
    }

    public Entity getEntity(int level,int haschild){
        Entity E=new Entity();
        //System.out.println("INGU VANTHEN");
        E.Name="Level "+level;
        if (cnt == 0 )
        {
            E.Name=" Debanjan Dev";
        }
        if (cnt == 1 )
        {
            E.Name=" S Viswanathan";
        }
        if (cnt == 2 )
        {
            E.Name=" Sanjay Manot";
        }
        if (cnt == 3 )
        {
            E.Name=" Manoj Tripati";
        }       
        if (cnt == 4 )
        {
            E.Name=" Narayanan";
        }
        if (cnt == 5 )
        {
            E.Name=" Sukumaran Chandrasingh";
        }
        if (cnt == 6 )
        {
            E.Name=" Jothi Ganesh";
        }       
        if (cnt == 7 )
        {
            E.Name=" Jesupillai Jacob ";
        }       
        if (cnt == 8 )
        {
            E.Name=" Vinodh Ramadoss ";
        }
        if (cnt == 9 )
        {
            E.Name=" Paul Chellappa ";
        }
        if (cnt == 10 )
        {
            E.Name=" Subramani Sundaramurthi ";
        }


        cnt = cnt+1;
        Log.d("details","Inguvanthen");
        E.isOpened=false;
        E.level=level;
        E.HasChild=haschild;
        return E;
    }
    public void populateList()
    {
        try
        {
            for(int i=0;i<2;i++){
                    arrTrades.add(getEntity(0, 1));
            }
            adapter=new ListAdapter(MultilevelTreeListView.this, R.id.row_cell_text_multilevel, arrTrades);
            mainList.setAdapter(adapter);
        }
        catch (Exception e)
        {
            Log.d(" populateList Exception",""+e.getMessage());
        }
    }
    public void CellButtonClick(View v){
        try{
            Button b=(Button)v;
            int index;
            index=(Integer) b.getTag();
            if(b.getText().toString().equals("+")){
                b.setText("-");

                Entity temp[]=new Entity[3];
                int PLevel=arrTrades.get(index).level+1;
                for(int i=0;i<3;i++){
                    temp[i]=getEntity(PLevel, 1);
                }
                arrTrades.get(index).isOpened=true;
                if(temp!=null){
                    int addindex=index+1;
                    for(int i=0;i<temp.length;i++){
                        arrTrades.add(addindex, temp[i]);
                        addindex++;
                    }
                }
                temp=null;
            }
            else{
                b.setText("+");
                cnt = cnt - 3;
                arrTrades.get(index).isOpened=false;
                    int removeindex=index+1;
                    for(int i=0;i<3;i++){
                        if(arrTrades.get(removeindex).isOpened){
                            removeChilds(removeindex);
                        }
                        arrTrades.remove(removeindex);
                    }
                }


            adapter.notifyDataSetChanged();
        }
        catch(Exception e){
            adapter.notifyDataSetChanged();
            Log.d("Error=", ""+e.getMessage());
        }
    }
    public void removeChilds(int index){
        try {
                int removeindex=index+1;
                for(int i=0;i<2;i++){
                    if(arrTrades.get(removeindex).isOpened){
                        removeChilds(removeindex);
                    }
                    arrTrades.remove(removeindex);
                }
        } catch (Exception e) {
            // TODO: handle exception
            Log.d("Errro=", ""+e.getMessage());
        }
    }
}

2 Answers 2

0
<intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

This should only be for one activity that u want start at start up of ur activity, remove for MultilevelTreeListView

0

Remove this:

         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

from your MultilevelTreeListView in your Android Manifest.

Also change the word DEFAULT for LAUNCHER in your MainLauncher activity

  <activity
        android:name="com.jd.multileveltreelistview.MainLauncher"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name="com.jd.multileveltreelistview.MultilevelTreeListView"
        android:label="@string/hello_world" >
    </activity>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.